1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

viaplay: get the right id for the video and not the first one we see.

fixes: #450
fixes: #447
This commit is contained in:
Johan Andersson 2016-09-14 20:52:14 +02:00
parent 61b512849b
commit 89789b843b

View File

@ -47,7 +47,10 @@ class Viaplay(Service, OpenGraphThumbMixin):
match = re.search('params":({.*}),"query', self.get_urldata())
if match:
jansson = json.loads(match.group(1))
season = jansson["seasonNumberOrVideoId"]
if "seasonNumberOrVideoId" in jansson:
season = jansson["seasonNumberOrVideoId"]
else:
return False
if "videoIdOrEpisodeNumber" in jansson:
videp = jansson["videoIdOrEpisodeNumber"]
match = re.search('(episode|avsnitt)-(\d+)', videp)
@ -56,6 +59,9 @@ class Viaplay(Service, OpenGraphThumbMixin):
else:
episodenr = videp
clips = True
match = re.search('(s\w+)-(\d+)', season)
if match:
season = match.group(2)
else:
episodenr = season
@ -67,7 +73,7 @@ class Viaplay(Service, OpenGraphThumbMixin):
janson = json.loads(match.group(1))
for i in janson["format"]["videos"].keys():
for n in janson["format"]["videos"][i]["program"]:
if str(n["episodeNumber"]) and int(episodenr) == n["episodeNumber"]:
if str(n["episodeNumber"]) and int(episodenr) == n["episodeNumber"] and int(season) == n["seasonNumber"]:
return n["id"]
elif n["id"] == episodenr:
return episodenr