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-04-21 12:44:31 +02:00
|
|
|
from svtplay_dl.service import Service
|
2013-03-17 19:55:19 +01:00
|
|
|
from svtplay_dl.utils import get_http_data, select_quality
|
|
|
|
from svtplay_dl.fetcher.rtmp import download_rtmp
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2013-04-21 12:44:31 +02:00
|
|
|
class Dr(Service):
|
2013-01-17 00:21:47 +01:00
|
|
|
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)
|
2013-09-14 19:03:50 +02:00
|
|
|
tempresource = resource['Data'][0]['Assets']
|
|
|
|
# To find the VideoResource, they have Images as well
|
|
|
|
for resources in tempresource:
|
|
|
|
if resources['Kind'] == 'VideoResource':
|
2013-09-14 21:58:55 +02:00
|
|
|
links = resources['Links']
|
|
|
|
break
|
|
|
|
|
|
|
|
streams = {}
|
|
|
|
for i in links:
|
|
|
|
if i["Target"] == "Streaming":
|
|
|
|
stream = {}
|
|
|
|
stream["uri"] = i["Uri"]
|
|
|
|
streams[int(i["Bitrate"])] = stream
|
|
|
|
|
|
|
|
if len(streams) == 1:
|
|
|
|
test = streams[list(streams.keys())[0]]
|
|
|
|
else:
|
|
|
|
test = select_quality(options, streams)
|
|
|
|
|
|
|
|
options.other = "-y '%s'" % test["uri"].replace("rtmp://vod.dr.dk/cms/", "")
|
|
|
|
rtmp = "rtmp://vod.dr.dk/cms/"
|
|
|
|
download_rtmp(options, rtmp)
|
2013-01-17 00:21:47 +01:00
|
|
|
|