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-03-01 23:39:42 +01:00
|
|
|
from svtplay.utils import get_http_data, select_quality
|
|
|
|
from svtplay.rtmp import download_rtmp
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2013-01-17 00:21:47 +01:00
|
|
|
class Dr(object):
|
|
|
|
def handle(self, url):
|
|
|
|
return "dr.dk" in url
|
|
|
|
|
|
|
|
def get(self, options, url):
|
|
|
|
data = get_http_data(url)
|
|
|
|
match = re.search(r'resource:[ ]*"([^"]*)",', data)
|
|
|
|
resource_url = match.group(1)
|
|
|
|
resource_data = get_http_data(resource_url)
|
|
|
|
resource = json.loads(resource_data)
|
|
|
|
streams = {}
|
|
|
|
for stream in resource['links']:
|
|
|
|
streams[stream['bitrateKbps']] = stream['uri']
|
|
|
|
if len(streams) == 1:
|
|
|
|
uri = streams[list(streams.keys())[0]]
|
|
|
|
else:
|
|
|
|
uri = select_quality(options, streams)
|
|
|
|
# need -v ?
|
|
|
|
options.other = "-v -y '" + uri.replace("rtmp://vod.dr.dk/cms/", "") + "'"
|
|
|
|
download_rtmp(options, uri)
|
|
|
|
|