Hi Olof,
I acted on this primarily to prevent the buggy 1.8-1 from ending up in
Ubuntu 17.04. Thanks to Mattia it's now fixed in both 17.04 and unstable.
I have uploaded a more spot on fix to this PPA (debdiff attached):
https://launchpad.net/~gunnarhj/+archive/ubuntu/svtplay-dl
I assumed that this bug report can be reopened for the purpose.
HTH
--
Gunnar Hjalmarsson
https://launchpad.net/~gunnarhj
diff -ru svtplay-dl-1.8.orig/debian/changelog svtplay-dl-1.8/debian/changelog
--- svtplay-dl-1.8.orig/debian/changelog 2016-11-15 20:25:32.000000000
+0100
+++ svtplay-dl-1.8/debian/changelog 2017-02-08 22:33:06.445766021 +0100
@@ -1,3 +1,10 @@
+svtplay-dl (1.8-1.1~ppa) yakkety; urgency=medium
+
+ * debian/patches/debian-changes:
+ Fix KeyError crash, issue #528. Closes: #853772
+
+ -- Gunnar Hjalmarsson <gunna...@ubuntu.com> Wed, 08 Feb 2017 22:33:00 +0100
+
svtplay-dl (1.8-1) unstable; urgency=medium
* New upstream version 1.8
diff -ru svtplay-dl-1.8.orig/debian/patches/debian-changes
svtplay-dl-1.8/debian/patches/debian-changes
--- svtplay-dl-1.8.orig/debian/patches/debian-changes 2016-11-15
20:25:32.000000000 +0100
+++ svtplay-dl-1.8/debian/patches/debian-changes 2017-02-08
22:31:18.837408272 +0100
@@ -32,3 +32,118 @@
svtplay-dl: $(PYFILES)
@# Verify that there's no .build already \
+
+Description: Fix KeyError crash
+Origin: https://github.com/spaam/svtplay-dl/commit/dac1b6
+Bug: https://bugs.debian.org/853772
+
+--- a/lib/svtplay_dl/service/svtplay.py 2016-11-14 23:53:49.000000000
+0100
++++ b/lib/svtplay_dl/service/svtplay.py 2017-02-08 21:56:34.415324777
+0100
+@@ -50,16 +50,22 @@
+ for i in janson["video"]["subtitles"]:
+ if i["format"] == "WebSRT":
+ yield subtitle(copy.copy(self.options), "wrst", i["url"])
++ if "programVersionId" in janson["video"]:
++ vid = janson["video"]["programVersionId"]
++ else:
++ vid = janson["video"]["id"]
++ res =
self.http.get("http://api.svt.se/videoplayer-api/video/{}".format(vid))
++ janson = res.json()
+
+- if "videoReferences" in janson["video"]:
+- if len(janson["video"]["videoReferences"]) == 0:
++ if "videoReferences" in janson:
++ if len(janson["videoReferences"]) == 0:
+ yield ServiceError("Media doesn't have any associated videos
(yet?)")
+ return
+
+- for i in janson["video"]["videoReferences"]:
++ for i in janson["videoReferences"]:
+ parse = urlparse(i["url"])
+ query = parse_qs(parse.query)
+- if i["playerType"] == "hls" or i["playerType"] == "ios":
++ if i["format"] == "hls":
+ streams = hlsparse(self.options, self.http.request("get",
i["url"]), i["url"])
+ if streams:
+ for n in list(streams.keys()):
+@@ -71,7 +77,7 @@
+ if streams:
+ for n in list(streams.keys()):
+ yield streams[n]
+- if i["playerType"] == "playerType" or i["playerType"] ==
"flash":
++ if i["format"] == "hds":
+ match = re.search(r"\/se\/secure\/", i["url"])
+ if not match:
+ streams = hdsparse(self.options,
self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"])
+@@ -85,7 +91,7 @@
+ if streams:
+ for n in list(streams.keys()):
+ yield streams[n]
+- if i["playerType"] == "dash264" or i["playerType"] ==
"dashhbbtv":
++ if i["format"] == "dash264" or i["format"] == "dashhbbtv":
+ streams = dashparse(self.options,
self.http.request("get", i["url"]), i["url"])
+ if streams:
+ for n in list(streams.keys()):
+@@ -119,7 +125,7 @@
+
+ def _genre(self, jansson):
+ videos = []
+- for i in jansson["clusterPage"]["content"]["clips"]:
++ for i in jansson["clusterPage"]["clips"]:
+ videos.append(i["contentUrl"])
+ return videos
+
+@@ -147,16 +153,16 @@
+ if re.search("/genre", parse.path):
+ videos = self._genre(dataj)
+ else:
+- items = dataj["videoTitlePage"]["realatedVideosTabs"]
++ items = dataj["videoTitlePage"]["relatedVideosTabs"]
+ for i in items:
+ if "sasong" in i["slug"]:
+ for n in i["videos"]:
+- if n["url"] not in videos:
+- videos.append(n["url"])
++ if n["contentUrl"] not in videos:
++ videos.append(n["contentUrl"])
+ if "senast" in i["slug"]:
+ for n in i["videos"]:
+- if n["url"] not in videos:
+- videos.append(n["url"])
++ if n["contentUrl"] not in videos:
++ videos.append(n["contentUrl"])
+
+ episodes = [urljoin("http://www.svtplay.se", x) for x in videos]
+ else:
+@@ -175,8 +181,9 @@
+
+ def outputfilename(self, data, filename):
+ directory = os.path.dirname(filename)
+- name = data["video"]["titlePagePath"]
++ name = filenamify(data["video"]["programTitle"])
+ other = filenamify(data["video"]["title"])
++
+ if "programVersionId" in data["video"]:
+ vid = str(data["video"]["programVersionId"])
+ else:
+@@ -188,6 +195,9 @@
+
+ if name == other:
+ other = None
++ elif name == None:
++ name = other
++ other = None
+ season = self.seasoninfo(data)
+ title = name
+ if season:
+@@ -202,9 +212,8 @@
+ output = title
+ return output
+
+-
+ def seasoninfo(self, data):
+- if "season" in data["video"]:
++ if "season" in data["video"] and data["video"]["season"]:
+ season = data["video"]["season"]
+ if season < 10:
+ season = "0%s" % season