-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1578 from glensc/episodes
Refactor: Implement shows sync using episodes
- Loading branch information
Showing
6 changed files
with
134 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from functools import cached_property | ||
from typing import TYPE_CHECKING | ||
|
||
from plextraktsync.plex.PlexLibraryItem import PlexLibraryItem | ||
|
||
if TYPE_CHECKING: | ||
from plexapi.library import ShowSection | ||
|
||
from plextraktsync.plex.PlexApi import PlexApi | ||
|
||
|
||
class PlexShowSectionPager: | ||
def __init__(self, section: ShowSection, plex: PlexApi): | ||
self.section = section | ||
self.plex = plex | ||
|
||
def __len__(self): | ||
return self.total_size | ||
|
||
@cached_property | ||
def total_size(self): | ||
return self.section.totalViewSize(libtype="episode") | ||
|
||
def __iter__(self): | ||
from plexapi import X_PLEX_CONTAINER_SIZE | ||
|
||
max_items = self.total_size | ||
start = 0 | ||
size = X_PLEX_CONTAINER_SIZE | ||
|
||
while True: | ||
items = self.section.searchEpisodes(container_start=start, container_size=size, maxresults=size) | ||
|
||
if not len(items): | ||
break | ||
|
||
for ep in items: | ||
yield PlexLibraryItem(ep, plex=self.plex) | ||
|
||
start += size | ||
if start > max_items: | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters