2013-03-02 21:26:28 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2013-03-01 23:39:42 +01:00
|
|
|
from __future__ import absolute_import
|
2013-02-12 19:43:37 +01:00
|
|
|
import re
|
|
|
|
import json
|
2013-12-30 01:39:05 +01:00
|
|
|
import sys
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2014-01-26 01:51:53 +01:00
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
2013-03-17 19:55:19 +01:00
|
|
|
from svtplay_dl.utils import get_http_data, select_quality
|
2014-04-21 18:26:43 +02:00
|
|
|
from svtplay_dl.fetcher.rtmp import RTMP
|
|
|
|
from svtplay_dl.fetcher.hls import HLS
|
2013-12-30 01:39:05 +01:00
|
|
|
from svtplay_dl.log import log
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2014-01-26 01:51:53 +01:00
|
|
|
class Dr(Service, OpenGraphThumbMixin):
|
2014-01-01 14:57:17 +01:00
|
|
|
supported_domains = ['dr.dk']
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2014-01-06 23:14:06 +01:00
|
|
|
def get(self, options):
|
2014-02-18 16:48:53 +01:00
|
|
|
data = self.get_urldata()
|
2013-01-17 00:21:47 +01:00
|
|
|
match = re.search(r'resource:[ ]*"([^"]*)",', data)
|
2013-09-14 22:39:37 +02:00
|
|
|
if match:
|
|
|
|
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
|
2013-09-14 21:58:55 +02:00
|
|
|
|
2013-09-14 22:39:37 +02:00
|
|
|
for i in links:
|
2014-04-21 18:26:43 +02:00
|
|
|
if i["Target"] == "Ios":
|
|
|
|
yield HLS(options, i["Uri"], i["Bitrate"])
|
2013-09-14 22:39:37 +02:00
|
|
|
else:
|
|
|
|
if i["Target"] == "Streaming":
|
2014-04-21 18:26:43 +02:00
|
|
|
options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "")
|
|
|
|
rtmp = "rtmp://vod.dr.dk/cms/"
|
|
|
|
yield RTMP(options, rtmp, i["Bitrate"])
|
2013-09-14 22:39:37 +02:00
|
|
|
|
2013-09-14 21:58:55 +02:00
|
|
|
else:
|
2013-09-14 22:39:37 +02:00
|
|
|
match = re.search(r'resource="([^"]*)"', data)
|
|
|
|
if not match:
|
|
|
|
log.error("Cant find resource info for this video")
|
|
|
|
sys.exit(2)
|
|
|
|
resource_url = "http://www.dr.dk%s" % match.group(1)
|
|
|
|
resource_data = get_http_data(resource_url)
|
|
|
|
resource = json.loads(resource_data)
|
2013-09-14 21:58:55 +02:00
|
|
|
|
2014-04-21 18:26:43 +02:00
|
|
|
for stream in resource['links']:
|
|
|
|
options.other = "-v -y '%s'" % stream['uri'].replace("rtmp://vod.dr.dk/cms/", "")
|
|
|
|
rtmp = "rtmp://vod.dr.dk/cms/"
|
|
|
|
yield RTMP(options, rtmp, stream['bitrateKbps'])
|