1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +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_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"])