Skip to content

Commit

Permalink
Merge pull request #173 from glensc/movies-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Apr 5, 2021
2 parents c027404 + e2a73f0 commit e7f31d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
16 changes: 7 additions & 9 deletions plex_trakt_sync/commands/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ def sync_all():
logging.info("Server version {} updated at: {}".format(server.version, server.updatedAt))
logging.info("Recently added: {}".format(server.library.recentlyAdded()[:5]))

for section in plex.library_sections:
if PlexApi.is_movie(section):
with measure_time("Processing section %s" % section.title):
process_movie_section(section, trakt_watched_movies, trakt_ratings, listutil, trakt_movie_collection)
elif PlexApi.is_show(section):
with measure_time("Processing section %s" % section.title):
process_show_section(section, trakt_watched_shows, listutil)
else:
continue
for section in plex.movie_sections:
with measure_time("Processing section %s" % section.title):
process_movie_section(section, trakt_watched_movies, trakt_ratings, listutil, trakt_movie_collection)

for section in plex.show_sections:
with measure_time("Processing section %s" % section.title):
process_show_section(section, trakt_watched_shows, listutil)

with measure_time("Updated plex watchlist"):
listutil.updatePlexLists(server)
Expand Down
30 changes: 22 additions & 8 deletions plex_trakt_sync/plex_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ class PlexApi:
def __init__(self, plex_server):
self.plex_server = plex_server

@property
@memoize
def movie_sections(self):
result = []
for section in self.library_sections:
if not type(section) is MovieSection:
continue
result.append(section)

return result

@property
@memoize
def show_sections(self):
result = []
for section in self.library_sections:
if not type(section) is ShowSection:
continue
result.append(section)

return result

@property
@memoize
@nocache
Expand All @@ -22,11 +44,3 @@ def library_sections(self):
result.append(section)

return result

@staticmethod
def is_movie(section):
return type(section) is MovieSection

@staticmethod
def is_show(section):
return type(section) is ShowSection

0 comments on commit e7f31d6

Please sign in to comment.