Skip to content

Commit

Permalink
Remove _get_episodes wrapper
Browse files Browse the repository at this point in the history
With @flatten_list can use yield and @Retry together
  • Loading branch information
glensc committed Jan 5, 2024
1 parent 5bb5966 commit 7e02987
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
16 changes: 8 additions & 8 deletions plextraktsync/plex/PlexLibraryItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from trakt.utils import timestamp

from plextraktsync.decorators.flatten import flatten_list
from plextraktsync.decorators.retry import retry
from plextraktsync.factory import factory
from plextraktsync.plex.PlexGuid import PlexGuid
Expand Down Expand Up @@ -300,19 +301,18 @@ def watch_progress(self, view_offset):
percent = view_offset / self.item.duration * 100
return percent

def episodes(self):
for ep in self._get_episodes():
yield PlexLibraryItem(ep, show=self.item, plex=self.plex)

@retry()
def _get_episodes(self):
@flatten_list
def episodes(self):
if self.type == "season":
show_id = self.item.parentRatingKey
season = self.item.seasonNumber
filters = {"show.id": show_id, "season.index": season}
else:
filters = {"show.id": self.item.ratingKey}

return self.library.search(libtype='episode', filters={'show.id': show_id, 'season.index': season})

return self.library.search(libtype='episode', filters={'show.id': self.item.ratingKey})
for ep in self.library.search(libtype="episode", filters=filters):
yield PlexLibraryItem(ep, show=self.item, plex=self.plex)

@cached_property
def season_number(self):
Expand Down
7 changes: 0 additions & 7 deletions plextraktsync/walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from typing import TYPE_CHECKING, NamedTuple

from plextraktsync.decorators.measure_time import measure_time
# <<<<<<< HEAD
from plextraktsync.mixin.SetWindowTitle import SetWindowTitle
from plextraktsync.plex.PlexGuid import PlexGuid
from plextraktsync.plex.PlexLibraryItem import PlexLibraryItem
from plextraktsync.trakt.TraktApi import TraktApi
from plextraktsync.trakt.TraktItem import TraktItem
Expand All @@ -20,11 +18,6 @@
from plextraktsync.media import Media, MediaFactory
from plextraktsync.plex.PlexApi import PlexApi
from plextraktsync.plex.PlexLibrarySection import PlexLibrarySection
# =======
# from plextraktsync.media import Media, MediaFactory
# from plextraktsync.plex_api import PlexApi, PlexLibraryItem, PlexLibrarySection
# from plextraktsync.trakt_api import TraktApi, TraktItem
# >>>>>>> f10d7a3e (Pass show property when creating PlexLibraryItem)


class WalkConfig:
Expand Down

0 comments on commit 7e02987

Please sign in to comment.