dev: bump to 0.1.84.0-dev Trakt Weiterschauen via watched/shows, Specials überspringen
This commit is contained in:
@@ -370,6 +370,40 @@ class TraktClient:
|
||||
return []
|
||||
return self._parse_history_items(payload)
|
||||
|
||||
def get_watched_shows(self, token: str) -> list[TraktItem]:
|
||||
"""GET /users/me/watched/shows – alle Serien mit zuletzt gesehener Episode."""
|
||||
status, payload = self._get("/users/me/watched/shows", token=token)
|
||||
if status != 200 or not isinstance(payload, list):
|
||||
self._do_log(f"get_watched_shows: status={status}")
|
||||
return []
|
||||
result: list[TraktItem] = []
|
||||
for entry in payload:
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
show = entry.get("show") or {}
|
||||
ids = self._parse_ids((show.get("ids") or {}))
|
||||
title = str(show.get("title", "") or "")
|
||||
year = int(show.get("year", 0) or 0)
|
||||
seasons = entry.get("seasons") or []
|
||||
last_season = 0
|
||||
last_episode = 0
|
||||
for s in seasons:
|
||||
snum = int((s.get("number") or 0))
|
||||
if snum == 0: # Specials überspringen
|
||||
continue
|
||||
for ep in (s.get("episodes") or []):
|
||||
enum = int((ep.get("number") or 0))
|
||||
if snum > last_season or (snum == last_season and enum > last_episode):
|
||||
last_season = snum
|
||||
last_episode = enum
|
||||
if title:
|
||||
result.append(TraktItem(
|
||||
title=title, year=year, media_type="episode",
|
||||
ids=ids, season=last_season, episode=last_episode,
|
||||
))
|
||||
self._do_log(f"get_watched_shows: {len(result)} Serien")
|
||||
return result
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Calendar
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user