Add find_by_guid method
from plex_trakt_sync.config import CONFIG
from plex_trakt_sync import pytrakt_extensions
from plex_trakt_sync.path import pytrakt_file
-from plex_trakt_sync.plex_api import PlexLibraryItem
+from plex_trakt_sync.plex_api import PlexLibraryItem, PlexGuid
class ScrobblerProxy:
@@ -206,6 +206,14 @@ def lookup(self, tm: TVShow):
"""
return pytrakt_extensions.lookup_table(tm)
+ @memoize
+ def find_by_guid(self, guid: PlexGuid):
+ if guid.type == "episode" and guid.is_episode:
+ ts = self.search_by_id(guid.show_id, id_type=guid.provider, media_type="show")
+ return self.find_episode(ts, guid.pm)
+
+ return self.search_by_id(guid.id, id_type=guid.provider, media_type=guid.type)
+
@memoize
def find_by_media(self, pm: PlexLibraryItem):
if pm.type == "episode" and pm.is_episode:
