From 8ba673dd2a5902faebafcdf96785d29c33d6274d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 22 Dec 2022 20:24:54 +0200 Subject: [PATCH 1/2] Update PlexLibraryItem __repr__ to understand online ids --- plextraktsync/plex/PlexLibraryItem.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plextraktsync/plex/PlexLibraryItem.py b/plextraktsync/plex/PlexLibraryItem.py index 6bd04c13ad..b431000ca9 100644 --- a/plextraktsync/plex/PlexLibraryItem.py +++ b/plextraktsync/plex/PlexLibraryItem.py @@ -277,10 +277,20 @@ def date_value(date): def __repr__(self): try: guid = self.guids[0] - return f"<{guid.provider}:{guid.id}:{str(self.item).strip('<>')}>" except IndexError: return f"<{self.item}>" + plex = str(self.item).strip('<>') + + # assemble ourselves to handle online sources nan issue + # https://github.com/pkkid/python-plexapi/issues/1072 + if not isinstance(self.item.ratingKey, int): + parts = plex.split(":") + parts[1] = self.item._data.attrib.get("ratingKey") + plex = ":".join(parts) + + return f"<{guid.provider}:{guid.id}:{plex}>" + def to_json(self): collected_at = None if not self.collected_at else timestamp( self.collected_at) From a9f99805460642053e8d98f3f506d76325b8c4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 11 Jan 2023 18:07:42 +0200 Subject: [PATCH 2/2] Get original ratingKey from guid PlexAPI way --- plextraktsync/plex/PlexLibraryItem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plextraktsync/plex/PlexLibraryItem.py b/plextraktsync/plex/PlexLibraryItem.py index b431000ca9..59cabb4b87 100644 --- a/plextraktsync/plex/PlexLibraryItem.py +++ b/plextraktsync/plex/PlexLibraryItem.py @@ -286,7 +286,7 @@ def __repr__(self): # https://github.com/pkkid/python-plexapi/issues/1072 if not isinstance(self.item.ratingKey, int): parts = plex.split(":") - parts[1] = self.item._data.attrib.get("ratingKey") + parts[1] = self.item.guid.rsplit('/', 1)[-1] plex = ":".join(parts) return f"<{guid.provider}:{guid.id}:{plex}>"