1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-28 06:04:17 +01:00

Viafree: Added check to prevent crash while naming clips

Added check to only get parent season and episode number if derived_from_id actually is set. Prevent crashes on some clips.
This commit is contained in:
qnorsten 2017-02-11 10:19:57 +01:00
parent 1f49d84664
commit 9cfb4e5f1e

View File

@ -231,7 +231,6 @@ class Viaplay(Service, OpenGraphThumbMixin):
if len(dataj["format_position"]["episode"]) > 0:
episode = dataj["format_position"]["episode"]
if dataj["type"] == "clip":
#Removes the show name from the end of the filename
#e.g. Showname.S0X.title instead of Showname.S07.title-showname
@ -240,10 +239,11 @@ class Viaplay(Service, OpenGraphThumbMixin):
title = filenamify(match.group(1))
else:
title = filenamify(dataj["title"])
if dataj["derived_from_id"] > 0:
if "derived_from_id" in dataj:
if dataj["derived_from_id"]:
parent_id = dataj["derived_from_id"]
parent_episode = self.http.request("get", "http://playapi.mtgx.tv/v3/videos/%s" % parent_id)
if parentepisode.status_code != 403: #if not geoblocked
if parent_episode.status_code != 403: #if not geoblocked
datajparent = json.loads(parent_episode.text)
if not season and datajparent["format_position"]["season"] > 0:
season = datajparent["format_position"]["season"]