From 46077b7cd24488e79a0c2fae76d7ad63741e36c8 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sun, 9 Apr 2023 21:32:39 +0200 Subject: [PATCH] svtplay: improve detection of episode number --- lib/svtplay_dl/service/svtplay.py | 11 +++++++---- lib/svtplay_dl/utils/stream.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/svtplay_dl/service/svtplay.py b/lib/svtplay_dl/service/svtplay.py index fd549e8..213e1e5 100644 --- a/lib/svtplay_dl/service/svtplay.py +++ b/lib/svtplay_dl/service/svtplay.py @@ -322,10 +322,13 @@ class Svtplay(Service, MetadataThumbMixin): vid = data["video"]["svtId"] for seasons in data["associatedContent"]: for i in seasons["items"]: - if i["item"]["videoSvtId"] == vid and "positionInSeason" in i["item"]: - match = re.search(r"Avsnitt (\d+)", i["item"]["positionInSeason"]) - if match: - return match.group(1) + if i["item"]["videoSvtId"] == vid: + if "positionInSeason" in i["item"]: + match = re.search(r"Avsnitt (\d+)", i["item"]["positionInSeason"]) + if match: + return match.group(1) + if "number" in i["item"]: + return i["item"]["number"] if "description" in data: match = re.search(r"Del (\d+) av (\d+)", data["description"]) diff --git a/lib/svtplay_dl/utils/stream.py b/lib/svtplay_dl/utils/stream.py index 440658b..8b6addf 100644 --- a/lib/svtplay_dl/utils/stream.py +++ b/lib/svtplay_dl/utils/stream.py @@ -166,7 +166,7 @@ def select_quality(config, streams): raise error.UIException(f"Can't find any streams with that audio language {config.get('audio_language')}") if config.get("resolution"): - resolutions = str(config.get("resolution")).split(",") + resolutions = config.get("resolution").split(",") streams = resolution(streams, resolutions) if not streams: raise error.UIException(f"Can't find any streams with that video resolution {config.get('resolution')}")