Skip to content

Commit

Permalink
Plex: only fetch watched or partially watched episodes
Browse files Browse the repository at this point in the history
Instead of fetching all episodes and checking if watched or view time it
is faster to search for only watched and partially watched episodes.

Signed-off-by: Luis Garcia <[email protected]>
  • Loading branch information
luigi311 committed Feb 19, 2025
1 parent 4d0f1d3 commit f3801a0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,14 @@ def get_user_library_watched(self, user, user_plex, library) -> LibraryData:
processed_shows.append(show.key)
show_guids = extract_guids_from_item(show)
episode_mediaitem = []
for episode in show.episodes():
if episode.isWatched or episode.viewOffset >= 60000:

episode_mediaitem.append(
get_mediaitem(episode, episode.isWatched)
)
# Fetch watched or partially watched episodes
for episode in show.watched() + show.episodes(
viewOffset__gte=60_000
):
episode_mediaitem.append(
get_mediaitem(episode, episode.isWatched)
)

if episode_mediaitem:
watched.series.append(
Expand Down

0 comments on commit f3801a0

Please sign in to comment.