Move logic of episode find to TraktLookup class
MODIFY
plextraktsync/trakt_api.py
plextraktsync/trakt_api.py
@@ -382,13 +382,10 @@ def find_episode_guid(self, guid: PlexGuid, lookup: TraktLookup):
"""
Find Trakt Episode from Guid of Plex Episode
"""
- te = lookup.from_number(guid.pm.season_number, guid.pm.episode_number)
- if not te or (str(te.ids.get(guid.provider)) != guid.id and not guid.pm.is_legacy_agent):
- te = lookup.from_id(guid.provider, guid.id)
+ te = lookup.from_guid(guid)
if te:
return te
- else:
- # Retry using search for specific Plex Episode
+
logger.warning(f"Retry using search for specific Plex Episode {guid.guid}")
if not guid.is_episode:
return self.find_by_guid(guid)
@@ -541,6 +538,16 @@ def _reverse_lookup(self, provider):
self.provider_table[provider] = table
logger.debug(f"{self.tm.title}: lookup table build with '{provider}' ids")
+ def from_guid(self, guid: PlexGuid):
+ """
+ Find Trakt Episode from Guid of Plex Episode
+ """
+ te = self.from_number(guid.pm.season_number, guid.pm.episode_number)
+ if not te or (str(te.ids.get(guid.provider)) != guid.id and not guid.pm.is_legacy_agent):
+ te = self.from_id(guid.provider, guid.id)
+
+ return te
+
def from_number(self, season, number):
if not self.table:
self.table = self._lookup(self.tm)

Move logic of episode find to TraktLookup class