Use PlexMedia typing
MODIFY
plextraktsync/plex/PlexApi.py
plextraktsync/plex/PlexApi.py
if TYPE_CHECKING:
from typing import Dict, List, Optional, Union
- from plexapi.video import Episode, Movie, Show
+ from plexapi.video import Movie, Show
+
+ from plextraktsync.plex.types import PlexMedia
class PlexApi:
@@ -140,7 +142,7 @@ def rate(self, m, rating):
m.rate(rating)
@staticmethod
- def same_list(list_a: List[Movie | Show | Episode], list_b: List[Movie | Show | Episode]) -> bool:
+ def same_list(list_a: List[PlexMedia], list_b: List[PlexMedia]) -> bool:
"""
Return true if two list contain same Plex items.
The comparison is made on ratingKey property,
@@ -157,7 +159,7 @@ def same_list(list_a: List[Movie | Show | Episode], list_b: List[Movie | Show |
return a == b
@nocache
- def update_playlist(self, name: str, items: List[Union[Movie, Show, Episode]], description=None) -> bool:
+ def update_playlist(self, name: str, items: List[PlexMedia], description=None) -> bool:
"""
Updates playlist (creates if name missing) replacing contents with items[]
"""

MODIFY
plextraktsync/plex/PlexLibraryItem.py
plextraktsync/plex/PlexLibraryItem.py
from plextraktsync.plex.PlexGuid import PlexGuid
if TYPE_CHECKING:
- from typing import List, Union
+ from typing import List
from plexapi.media import MediaPart
- from plexapi.video import Episode, Movie, Show
+
+ from plextraktsync.plex.types import PlexMedia
class PlexLibraryItem:
- def __init__(self, item: Union[Movie, Show, Episode], plex=None):
+ def __init__(self, item: PlexMedia, plex=None):
self.item = item
self.plex = plex

MODIFY
plextraktsync/plex/PlexLibrarySection.py
plextraktsync/plex/PlexLibrarySection.py
from typing import Optional, Union
from plexapi.library import LibrarySection
- from plexapi.video import Episode, Movie, Show
from plextraktsync.plex.PlexApi import PlexApi
+ from plextraktsync.plex.types import PlexMedia
class PlexLibrarySection:
@@ -47,7 +47,7 @@ def search(self, **kwargs):
return self.section.search(**kwargs)
@nocache
- def find_by_id(self, id: Union[str, int]) -> Optional[Union[Movie, Show, Episode]]:
+ def find_by_id(self, id: Union[str, int]) -> Optional[PlexMedia]:
try:
return self.section.fetchItem(int(id))
except NotFound:

Use PlexMedia typing