From 6345f5b93ea8b3dde9cc16eb1f29bd78233a914d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 12 Apr 2021 18:04:26 +0300 Subject: [PATCH] Merge collected_at for episodes collection --- plex_trakt_sync/trakt_api.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plex_trakt_sync/trakt_api.py b/plex_trakt_sync/trakt_api.py index e170d75cf4..54d7b092ed 100644 --- a/plex_trakt_sync/trakt_api.py +++ b/plex_trakt_sync/trakt_api.py @@ -166,8 +166,6 @@ def mark_watched(self, m, time): @nocache @rate_limit(delay=TRAKT_POST_DELAY) def add_to_collection(self, m, pm: PlexLibraryItem): - # support is missing, compose custom json ourselves - # https://github.com/moogar0880/PyTrakt/issues/143 if m.media_type == "movies": json = { m.media_type: [dict( @@ -177,9 +175,17 @@ def add_to_collection(self, m, pm: PlexLibraryItem): **pm.to_json(), )], } - return trakt.sync.add_to_collection(json) + elif m.media_type == "episodes": + json = { + m.media_type: [dict( + **m.ids, + **pm.to_json(), + )], + } else: - return m.add_to_library() + raise ValueError(f"Unsupported media type: {m.media_type}") + + return trakt.sync.add_to_collection(json) @memoize @nocache