keep trakt rank in playlist
MODIFY
main.py
main.py
@@ -284,7 +284,7 @@ def main():
#logging.debug("Movie collection from trakt:", trakt_movie_collection)
trakt_watched_shows = pytrakt_extensions.allwatched()
if CONFIG['sync']['watchlist']:
- listutil.addList(None, "Trakt Watchlist", list_set=set(
+ listutil.addList(None, "Trakt Watchlist", list_set=list(
map(lambda m: m.slug, trakt_user.watchlist_movies)))
#logging.debug("Movie watchlist from trakt:", trakt_movie_watchlist)
user_ratings = trakt_user.get_ratings(media_type='movies')

MODIFY
trakt_list_util.py
trakt_list_util.py
@@ -9,8 +9,9 @@ class TraktList():
def __init__(self, username, listname):
self.name = listname
self.plex_movies = []
+ self.list_order = []
if username != None:
- self.slugs = set(map(lambda m: m.slug, [elem for elem in UserList._get(listname, username).get_items() if type(elem) == Movie]))
+ self.slugs = list(map(lambda m: m.slug, [elem for elem in UserList._get(listname, username).get_items() if type(elem) == Movie]))
@staticmethod
def from_set(listname, list_set):
@@ -21,6 +22,7 @@ def from_set(listname, list_set):
def addPlexMovie(self, slug, plex_movie):
if slug in self.slugs:
self.plex_movies.append(plex_movie)
+ self.list_order.append(self.slugs.index(slug))
logging.info('Movie [{} ({})]: added to list {}'.format(plex_movie.title, plex_movie.year, self.name))
def updatePlexList(self, plex):
@@ -31,7 +33,8 @@ def updatePlexList(self, plex):
logging.error("Playlist %s not found, so it could not be deleted. Actual playlists: %s" % (self.name, plex.playlists()))
pass
if len(self.plex_movies) > 0:
- plex.createPlaylist(self.name, items=self.plex_movies)
+ _, plex_movies_sorted = zip(*sorted(zip(self.list_order, self.plex_movies)))
+ plex.createPlaylist(self.name, items=plex_movies_sorted)
class TraktListUtil():

keep trakt rank in playlist