From f01d97df9dee8c558ccbc5e7fdc239253604708c Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Tue, 1 Sep 2015 00:37:06 +0200 Subject: [PATCH] dr: use text for json and send the url to the playlist --- lib/svtplay_dl/service/dr.py | 45 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/svtplay_dl/service/dr.py b/lib/svtplay_dl/service/dr.py index 6fea4cb..832b249 100644 --- a/lib/svtplay_dl/service/dr.py +++ b/lib/svtplay_dl/service/dr.py @@ -26,7 +26,7 @@ class Dr(Service, OpenGraphThumbMixin): resource_url = match.group(1) resource_data = self.http.request("get", resource_url).content resource = json.loads(resource_data) - streams = find_stream(options, resource) + streams = self.find_stream(options, resource) for i in streams: yield i else: @@ -34,15 +34,16 @@ class Dr(Service, OpenGraphThumbMixin): if not match: log.error("Cant find resource info for this video") return - resource_url = "%s" % match.group(1) - resource_data = self.http.request("get", resource_url).content + resource_url = "http:%s" % match.group(1) + resource_data = self.http.request("get", resource_url).text resource = json.loads(resource_data) if "SubtitlesList" in resource: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(options), "wrst", suburl) if "Data" in resource: - streams = find_stream(options, resource) + + streams = self.find_stream(options, resource) for i in streams: yield i else: @@ -53,7 +54,7 @@ class Dr(Service, OpenGraphThumbMixin): for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": - streams = hlsparse(self.http.request("get", stream["Uri"]).text) + streams = hlsparse(stream["Uri"], self.http.request("get", stream["Uri"]).text) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if stream["Target"] == "Streaming": @@ -61,20 +62,20 @@ class Dr(Service, OpenGraphThumbMixin): rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, stream['Bitrate']) -def find_stream(options, resource): - tempresource = resource['Data'][0]['Assets'] - # To find the VideoResource, they have Images as well - for resources in tempresource: - if resources['Kind'] == 'VideoResource': - links = resources['Links'] - break - for i in links: - if i["Target"] == "Ios" or i["Target"] == "HLS": - streams = hlsparse(i["Uri"]) - for n in list(streams.keys()): - yield HLS(copy.copy(options), streams[n], n) - else: - if i["Target"] == "Streaming": - options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "") - rtmp = "rtmp://vod.dr.dk/cms/" - yield RTMP(copy.copy(options), rtmp, i["Bitrate"]) + def find_stream(self, options, resource): + tempresource = resource['Data'][0]['Assets'] + # To find the VideoResource, they have Images as well + for resources in tempresource: + if resources['Kind'] == 'VideoResource': + links = resources['Links'] + break + for i in links: + if i["Target"] == "Ios" or i["Target"] == "HLS": + streams = hlsparse(i["Uri"], self.http.request("get", i["Uri"]).text) + for n in list(streams.keys()): + yield HLS(copy.copy(options), streams[n], n) + else: + if i["Target"] == "Streaming": + options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "") + rtmp = "rtmp://vod.dr.dk/cms/" + yield RTMP(copy.copy(options), rtmp, i["Bitrate"])