mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-28 14:14:15 +01:00
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
# ex:ts=4:sw=4:sts=4:et
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
from __future__ import absolute_import
|
|
import re
|
|
import json
|
|
import sys
|
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
|
from svtplay_dl.utils import get_http_data, select_quality
|
|
from svtplay_dl.fetcher.rtmp import RTMP
|
|
from svtplay_dl.fetcher.hls import HLS
|
|
from svtplay_dl.log import log
|
|
|
|
class Dr(Service, OpenGraphThumbMixin):
|
|
supported_domains = ['dr.dk']
|
|
|
|
def get(self, options):
|
|
data = self.get_urldata()
|
|
match = re.search(r'resource:[ ]*"([^"]*)",', data)
|
|
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
|
|
|
|
for i in links:
|
|
if i["Target"] == "Ios":
|
|
yield HLS(options, i["Uri"], i["Bitrate"])
|
|
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(options, rtmp, i["Bitrate"])
|
|
|
|
else:
|
|
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)
|
|
|
|
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']) |