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

dr.dk: fixed a crash when looking on news videos

This commit is contained in:
Johan Andersson 2014-08-11 19:46:56 +02:00
parent 633a2254f0
commit 9b6f838e16

View File

@ -23,24 +23,9 @@ class Dr(Service, OpenGraphThumbMixin):
resource_url = match.group(1)
resource_data = get_http_data(resource_url)
resource = json.loads(resource_data)
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":
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"])
streams = find_stream(options, resource)
for i in streams:
yield i
else:
match = re.search(r'resource="([^"]*)"', data)
if not match:
@ -50,6 +35,11 @@ class Dr(Service, OpenGraphThumbMixin):
resource_data = get_http_data(resource_url)
resource = json.loads(resource_data)
if "Data" in resource:
streams = find_stream(options, resource)
for i in streams:
yield i
else:
for stream in resource['Links']:
if stream["Target"] == "HDS":
manifest = "%s?hdcore=2.8.0&g=hejsan" % stream["Uri"]
@ -64,3 +54,21 @@ class Dr(Service, OpenGraphThumbMixin):
options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")
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"])