Fixed NPO retrieving all seasons in series
This commit is contained in:
parent
3e0732987c
commit
1d39cf68e5
@ -105,41 +105,67 @@ class NPO(Service):
|
|||||||
|
|
||||||
def get_titles(self) -> Titles_T:
|
def get_titles(self) -> Titles_T:
|
||||||
next_data = self._fetch_next_data(self.slug)
|
next_data = self._fetch_next_data(self.slug)
|
||||||
build_id = next_data["buildId"] # keep if needed elsewhere
|
|
||||||
|
|
||||||
page_props = next_data["props"]["pageProps"]
|
page_props = next_data["props"]["pageProps"]
|
||||||
queries = page_props["dehydratedState"]["queries"]
|
queries = page_props["dehydratedState"]["queries"]
|
||||||
|
|
||||||
def get_data(fragment: str):
|
def get_query_data(fragment: str):
|
||||||
return next((q["state"]["data"] for q in queries if fragment in str(q.get("queryKey", ""))), None)
|
return next((q["state"]["data"] for q in queries if fragment in str(q.get("queryKey", ""))), None)
|
||||||
|
|
||||||
if self.kind == "serie":
|
if self.kind == "serie":
|
||||||
series_data = get_data("series:detail-")
|
series_data = get_query_data("series:detail-")
|
||||||
if not series_data:
|
if not series_data:
|
||||||
raise ValueError("Series metadata not found")
|
raise ValueError("Series metadata not found")
|
||||||
|
|
||||||
episodes = []
|
# Get list of all available seasons
|
||||||
seasons = get_data("series:seasons-") or []
|
seasons_list = get_query_data("series:seasons-") or []
|
||||||
for season in seasons:
|
if not seasons_list:
|
||||||
eps = get_data(f"programs:season-{season['guid']}") or []
|
self.log.warning("No seasons found for this series.")
|
||||||
for e in eps:
|
|
||||||
episodes.append(
|
all_episodes = []
|
||||||
|
series_type = series_data.get("type", "timeless_series")
|
||||||
|
|
||||||
|
for season in seasons_list:
|
||||||
|
season_guid = season["guid"]
|
||||||
|
season_number = int(season.get("seasonKey", 0))
|
||||||
|
|
||||||
|
# Try to find episode data in the initial page data first
|
||||||
|
eps_data = get_query_data(f"programs:season-{season_guid}")
|
||||||
|
|
||||||
|
# If not in initial data, fetch from the API
|
||||||
|
if not eps_data:
|
||||||
|
r = self.session.get(
|
||||||
|
self.config["endpoints"]["series_episodes"],
|
||||||
|
params={
|
||||||
|
"guid": season_guid,
|
||||||
|
"type": series_type,
|
||||||
|
"includePremiumContent": "true"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if r.ok:
|
||||||
|
eps_data = r.json()
|
||||||
|
|
||||||
|
if not eps_data:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for e in eps_data:
|
||||||
|
all_episodes.append(
|
||||||
Episode(
|
Episode(
|
||||||
id_=e["guid"],
|
id_=e["guid"],
|
||||||
service=self.__class__,
|
service=self.__class__,
|
||||||
title=series_data["title"],
|
title=series_data["title"],
|
||||||
season=int(season["seasonKey"]),
|
season=season_number,
|
||||||
number=int(e["programKey"]),
|
number=int(e.get("programKey") or 0),
|
||||||
name=e["title"],
|
name=e.get("title"),
|
||||||
description=(e.get("synopsis", {}) or {}).get("long", ""),
|
description=(e.get("synopsis", {}) or {}).get("long", ""),
|
||||||
language=Language.get("nl"),
|
language=Language.get("nl"),
|
||||||
data=e,
|
data=e,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return Series(episodes)
|
|
||||||
|
return Series(all_episodes)
|
||||||
|
|
||||||
# Movie
|
# Movie Logic
|
||||||
item = get_data("program:detail-") or queries[0]["state"]["data"]
|
item = get_query_data("program:detail-") or queries[0]["state"]["data"]
|
||||||
synopsis = item.get("synopsis", {})
|
synopsis = item.get("synopsis", {})
|
||||||
desc = synopsis.get("long") or synopsis.get("short", "") if isinstance(synopsis, dict) else str(synopsis)
|
desc = synopsis.get("long") or synopsis.get("short", "") if isinstance(synopsis, dict) else str(synopsis)
|
||||||
year = (int(item["firstBroadcastDate"]) // 31536000 + 1970) if item.get("firstBroadcastDate") else None
|
year = (int(item["firstBroadcastDate"]) // 31536000 + 1970) if item.get("firstBroadcastDate") else None
|
||||||
|
|||||||
@ -2,9 +2,10 @@ endpoints:
|
|||||||
metadata: "https://npo.nl/start/_next/data/{build_id}/video/{slug}.json"
|
metadata: "https://npo.nl/start/_next/data/{build_id}/video/{slug}.json"
|
||||||
metadata_series: "https://npo.nl/start/_next/data/{build_id}/serie/{slug}/afleveringen.json"
|
metadata_series: "https://npo.nl/start/_next/data/{build_id}/serie/{slug}/afleveringen.json"
|
||||||
metadata_episode: "https://npo.nl/start/_next/data/{build_id}/serie/{series_slug}/seizoen-{season_slug}/{episode_slug}.json"
|
metadata_episode: "https://npo.nl/start/_next/data/{build_id}/serie/{series_slug}/seizoen-{season_slug}/{episode_slug}.json"
|
||||||
|
series_episodes: "https://npo.nl/start/api/domain/programs-by-season"
|
||||||
streams: "https://prod.npoplayer.nl/stream-link"
|
streams: "https://prod.npoplayer.nl/stream-link"
|
||||||
player_token: "https://npo.nl/start/api/domain/player-token?productId={product_id}"
|
player_token: "https://npo.nl/start/api/domain/player-token?productId={product_id}"
|
||||||
license: "https://npo-drm-gateway.samgcloud.nepworldwide.nl/authentication"
|
license: "https://npo-drm-gateway.samgcloud.nepworldwide.nl/authentication"
|
||||||
homepage: "https://npo.nl/start"
|
homepage: "https://npo.nl/start"
|
||||||
search: " https://npo.nl/start/api/domain/search-collection-items"
|
search: "https://npo.nl/start/api/domain/search-collection-items"
|
||||||
DrmType: "widevine"
|
DrmType: "widevine"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user