From c1985a1dffbd85f5296abdef29895e4a67f7b681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 17 Aug 2024 11:38:57 +0300 Subject: [PATCH 1/5] Add original title property to PlexGuid --- plextraktsync/plex/PlexGuid.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plextraktsync/plex/PlexGuid.py b/plextraktsync/plex/PlexGuid.py index 598fa43aa3..bbc5265549 100644 --- a/plextraktsync/plex/PlexGuid.py +++ b/plextraktsync/plex/PlexGuid.py @@ -95,6 +95,10 @@ def guid_is_imdb_legacy(self): # old item, like imdb 'tt0112253' return guid[0:2] == "tt" and guid[2:].isnumeric() + @property + def title(self): + return self.pm.item.title + @property def title_link(self): if self.pm: From 068a26209154a8f6f78010b63b7e53f19a9a1f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 17 Aug 2024 11:39:19 +0300 Subject: [PATCH 2/5] Add title_link property to TraktItem --- plextraktsync/trakt/TraktItem.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plextraktsync/trakt/TraktItem.py b/plextraktsync/trakt/TraktItem.py index 8fed150c2e..0d8574b057 100644 --- a/plextraktsync/trakt/TraktItem.py +++ b/plextraktsync/trakt/TraktItem.py @@ -3,11 +3,13 @@ from functools import cached_property from typing import TYPE_CHECKING +from plextraktsync.mixin.RichMarkup import RichMarkup + if TYPE_CHECKING: from plextraktsync.trakt.types import TraktMedia -class TraktItem: +class TraktItem(RichMarkup): def __init__(self, item: TraktMedia): self.item = item @@ -22,3 +24,9 @@ def type(self): @property def guids(self): return {k: v for k, v in self.item.ids["ids"].items() if k in ["imdb", "tmdb", "tvdb"]} + + @property + def title_link(self): + link = f"https://trakt.tv/{self.item.ext}" + + return self.markup_link(link, self.item.title) From df288ab0502f929779c2a86fd54d5bed9ec48f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 17 Aug 2024 11:40:09 +0300 Subject: [PATCH 3/5] Unwrap else from find_by_guid --- plextraktsync/trakt/TraktApi.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plextraktsync/trakt/TraktApi.py b/plextraktsync/trakt/TraktApi.py index dc2a636fb6..b097700239 100644 --- a/plextraktsync/trakt/TraktApi.py +++ b/plextraktsync/trakt/TraktApi.py @@ -254,16 +254,16 @@ def find_by_episode_guid(self, guid: PlexGuid): def find_by_guid(self, guid: PlexGuid): if guid.type == "episode" and guid.is_episode: return self.find_by_episode_guid(guid) - else: - tm = self.search_by_id(guid.id, id_type=guid.provider, media_type=guid.type) - if tm is None and guid.type == "movie": - if self.search_by_id(guid.id, id_type=guid.provider, media_type="show"): - self.logger.warning( - f"Found match using show search: {guid.title_link}", - extra={"markup": True}, - ) - - return tm + + tm = self.search_by_id(guid.id, id_type=guid.provider, media_type=guid.type) + if tm is None and guid.type == "movie": + if self.search_by_id(guid.id, id_type=guid.provider, media_type="show"): + self.logger.warning( + f"Found match using show search: {guid.title_link}", + extra={"markup": True}, + ) + + return tm @staticmethod def find_by_slug(slug: str, media_type: str): From db3737930ee21de17f914aaa5c6684a62bc302d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 17 Aug 2024 11:40:23 +0300 Subject: [PATCH 4/5] Print trakt title of matched show --- plextraktsync/trakt/TraktApi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plextraktsync/trakt/TraktApi.py b/plextraktsync/trakt/TraktApi.py index b097700239..21d1bba465 100644 --- a/plextraktsync/trakt/TraktApi.py +++ b/plextraktsync/trakt/TraktApi.py @@ -24,6 +24,7 @@ from plextraktsync.factory import factory, logging from plextraktsync.path import pytrakt_file from plextraktsync.trakt.PartialTraktMedia import PartialTraktMedia +from plextraktsync.trakt.TraktItem import TraktItem from plextraktsync.trakt.TraktLookup import TraktLookup from plextraktsync.trakt.TraktRatingCollection import TraktRatingCollection from plextraktsync.trakt.WatchProgress import WatchProgress @@ -257,9 +258,11 @@ def find_by_guid(self, guid: PlexGuid): tm = self.search_by_id(guid.id, id_type=guid.provider, media_type=guid.type) if tm is None and guid.type == "movie": - if self.search_by_id(guid.id, id_type=guid.provider, media_type="show"): + show = self.search_by_id(guid.id, id_type=guid.provider, media_type="show") + if show: + ts = TraktItem(show) self.logger.warning( - f"Found match using show search: {guid.title_link}", + f"Found id match using show search: {guid.title_link}: {ts.title_link}", extra={"markup": True}, ) From 8e4ab36bbca87fad40e0b53b659f0ce4e1e38226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sat, 17 Aug 2024 11:41:53 +0300 Subject: [PATCH 5/5] Compare also that orignal titles match --- plextraktsync/trakt/TraktApi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plextraktsync/trakt/TraktApi.py b/plextraktsync/trakt/TraktApi.py index 21d1bba465..a13c5582ed 100644 --- a/plextraktsync/trakt/TraktApi.py +++ b/plextraktsync/trakt/TraktApi.py @@ -260,11 +260,12 @@ def find_by_guid(self, guid: PlexGuid): if tm is None and guid.type == "movie": show = self.search_by_id(guid.id, id_type=guid.provider, media_type="show") if show: - ts = TraktItem(show) - self.logger.warning( - f"Found id match using show search: {guid.title_link}: {ts.title_link}", - extra={"markup": True}, - ) + if guid.title == show.title: + ts = TraktItem(show) + self.logger.warning( + f"Found id match using show search: {guid.title_link}: {ts.title_link}", + extra={"markup": True}, + ) return tm