Skip to content

Commit

Permalink
Implement get_playback method
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Apr 7, 2024
1 parent 3cb44ae commit 9ebc163
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions trakt/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,27 @@ def get_playback(list_type=None):
https://trakt.docs.apiary.io/#reference/sync/playback/get-playback-progress
"""
valid_type = ("movies", "episodes")

if list_type and list_type not in valid_type:
raise ValueError(f"Invalid list_type: {list_type}. Must be one of {valid_type}")

uri = "sync/playback"
if list_type:
uri += f"/{list_type}"

items = yield uri
results = []
for item in items:
if "type" not in item:
continue
data = item.pop(item["type"])
if "show" in item:
data["show"] = item.pop("show")
results.append(PlaybackEntry(**item, data=data))

yield results


@get
def get_watchlist(list_type=None, sort=None):
Expand Down

0 comments on commit 9ebc163

Please sign in to comment.