From ad5399f5de2d2b58e3d046c4d2bb13311e4278a5 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sun, 16 Nov 2014 21:55:54 +0100 Subject: [PATCH] kanal5: proper error message when we try to access premium content --- lib/svtplay_dl/service/kanal5.py | 45 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/svtplay_dl/service/kanal5.py b/lib/svtplay_dl/service/kanal5.py index aeea4f7..ea87446 100644 --- a/lib/svtplay_dl/service/kanal5.py +++ b/lib/svtplay_dl/service/kanal5.py @@ -27,7 +27,7 @@ class Kanal5(Service): match = re.search(r".*video/([0-9]+)", self.url) if not match: log.error("Can't find video file") - sys.exit(2) + return video_id = match.group(1) if options.username and options.password: @@ -43,7 +43,7 @@ class Kanal5(Service): jsondata = json.loads(match.group(1)) if jsondata["success"] is False: log.error(jsondata["message"]) - sys.exit(2) + return authToken = jsondata["userData"]["auth"] cc = Cookie(version=0, name='authToken', value=authToken, @@ -77,23 +77,26 @@ class Kanal5(Service): if options.force_subtitle: return - for i in data["streams"]: - if i["drmProtected"]: - log.error("We cant download drm files for this site.") - sys.exit(2) - steambaseurl = data["streamBaseUrl"] - bitrate = i["bitrate"] - if bitrate > 1000: - bitrate = bitrate / 1000 - options2 = copy.copy(options) - options2.other = "-W %s -y %s " % ("http://www.kanal5play.se/flash/K5StandardPlayer.swf", i["source"]) - options2.live = True - yield RTMP(options2, steambaseurl, bitrate) - - url = "http://www.kanal5play.se/api/getVideo?format=IPAD&videoId=%s" % video_id - data = json.loads(get_http_data(url, cookiejar=self.cj)) - if "streams" in data.keys(): + if "streams" in data: for i in data["streams"]: - streams = hlsparse(i["source"]) - for n in list(streams.keys()): - yield HLS(copy.copy(options), streams[n], n) + if i["drmProtected"]: + log.error("We cant download drm files for this site.") + return + steambaseurl = data["streamBaseUrl"] + bitrate = i["bitrate"] + if bitrate > 1000: + bitrate = bitrate / 1000 + options2 = copy.copy(options) + options2.other = "-W %s -y %s " % ("http://www.kanal5play.se/flash/K5StandardPlayer.swf", i["source"]) + options2.live = True + yield RTMP(options2, steambaseurl, bitrate) + + url = "http://www.kanal5play.se/api/getVideo?format=IPAD&videoId=%s" % video_id + data = json.loads(get_http_data(url, cookiejar=self.cj)) + if "streams" in data.keys(): + for i in data["streams"]: + streams = hlsparse(i["source"]) + for n in list(streams.keys()): + yield HLS(copy.copy(options), streams[n], n) + if "reasonsForNoStreams" in data: + log.error(data["reasonsForNoStreams"][0])