Skip to content

Commit

Permalink
Merge collected_at for episodes collection
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Apr 12, 2021
1 parent b969b1c commit 6345f5b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plex_trakt_sync/trakt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 6345f5b

Please sign in to comment.