diff --git a/content/services/trakt.py b/content/services/trakt.py index 5af16aff8..28a847134 100644 --- a/content/services/trakt.py +++ b/content/services/trakt.py @@ -220,6 +220,9 @@ def __init__(self): if list.startswith(user[0] + "'s private list:"): list_type = "private" break + if list.startswith("local:"): + list_type = "local" + break current_user = user if list_type == "watchlist": try: @@ -248,6 +251,34 @@ def __init__(self): except Exception as e: ui_print("[trakt error]: (exception): " + str(e), debug=ui_settings.debug) continue + elif list_type == "local": + try: + path = regex.sub("^local:\s*","",list) + local_items = json.loads(open(path).read(), object_hook=lambda d: SimpleNamespace(**d)) + for element in local_items: + if hasattr(element, 'show'): + element.show.type = 'show' + element.show.user = user + element.show.guid = element.show.ids.trakt + try: + element.show.watchlistedAt = datetime.datetime.timestamp(datetime.datetime.strptime(element.listed_at,'%Y-%m-%dT%H:%M:%S.000Z')) + except: + element.show.watchlistedAt = 0 + if not element.show in self.data: + self.data.append(show(element.show)) + elif hasattr(element, 'movie'): + element.movie.type = 'movie' + element.movie.user = user + element.movie.guid = element.movie.ids.trakt + try: + element.movie.watchlistedAt = datetime.datetime.timestamp(datetime.datetime.strptime(element.listed_at,'%Y-%m-%dT%H:%M:%S.000Z')) + except: + element.movie.watchlistedAt = 0 + if not element.movie in self.data: + self.data.append(movie(element.movie)) + except Exception as e: + ui_print("[trakt error]: (exception): " + str(e), debug=ui_settings.debug) + continue elif list_type == "collection": try: watchlist_items, header = get('https://api.trakt.tv/sync/collection/shows?extended=full')