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

dr: use text for json and send the url to the playlist

This commit is contained in:
Johan Andersson 2015-09-01 00:37:06 +02:00
parent 421057194e
commit f01d97df9d

View File

@ -26,7 +26,7 @@ class Dr(Service, OpenGraphThumbMixin):
resource_url = match.group(1) resource_url = match.group(1)
resource_data = self.http.request("get", resource_url).content resource_data = self.http.request("get", resource_url).content
resource = json.loads(resource_data) resource = json.loads(resource_data)
streams = find_stream(options, resource) streams = self.find_stream(options, resource)
for i in streams: for i in streams:
yield i yield i
else: else:
@ -34,15 +34,16 @@ class Dr(Service, OpenGraphThumbMixin):
if not match: if not match:
log.error("Cant find resource info for this video") log.error("Cant find resource info for this video")
return return
resource_url = "%s" % match.group(1) resource_url = "http:%s" % match.group(1)
resource_data = self.http.request("get", resource_url).content resource_data = self.http.request("get", resource_url).text
resource = json.loads(resource_data) resource = json.loads(resource_data)
if "SubtitlesList" in resource: if "SubtitlesList" in resource:
suburl = resource["SubtitlesList"][0]["Uri"] suburl = resource["SubtitlesList"][0]["Uri"]
yield subtitle(copy.copy(options), "wrst", suburl) yield subtitle(copy.copy(options), "wrst", suburl)
if "Data" in resource: if "Data" in resource:
streams = find_stream(options, resource)
streams = self.find_stream(options, resource)
for i in streams: for i in streams:
yield i yield i
else: else:
@ -53,7 +54,7 @@ class Dr(Service, OpenGraphThumbMixin):
for n in list(streams.keys()): for n in list(streams.keys()):
yield streams[n] yield streams[n]
if stream["Target"] == "HLS": 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()): for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n) yield HLS(copy.copy(options), streams[n], n)
if stream["Target"] == "Streaming": if stream["Target"] == "Streaming":
@ -61,7 +62,7 @@ class Dr(Service, OpenGraphThumbMixin):
rtmp = "rtmp://vod.dr.dk/cms/" rtmp = "rtmp://vod.dr.dk/cms/"
yield RTMP(copy.copy(options), rtmp, stream['Bitrate']) yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
def find_stream(options, resource): def find_stream(self, options, resource):
tempresource = resource['Data'][0]['Assets'] tempresource = resource['Data'][0]['Assets']
# To find the VideoResource, they have Images as well # To find the VideoResource, they have Images as well
for resources in tempresource: for resources in tempresource:
@ -70,7 +71,7 @@ def find_stream(options, resource):
break break
for i in links: for i in links:
if i["Target"] == "Ios" or i["Target"] == "HLS": if i["Target"] == "Ios" or i["Target"] == "HLS":
streams = hlsparse(i["Uri"]) streams = hlsparse(i["Uri"], self.http.request("get", i["Uri"]).text)
for n in list(streams.keys()): for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n) yield HLS(copy.copy(options), streams[n], n)
else: else: