mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-28 06:04:17 +01:00
dr: convert into new video fetcher
This commit is contained in:
parent
30e23c171d
commit
28d8f453c8
@ -7,8 +7,8 @@ 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 download_rtmp
|
||||
from svtplay_dl.fetcher.hls import download_hls
|
||||
from svtplay_dl.fetcher.rtmp import RTMP
|
||||
from svtplay_dl.fetcher.hls import HLS
|
||||
from svtplay_dl.log import log
|
||||
|
||||
class Dr(Service, OpenGraphThumbMixin):
|
||||
@ -28,30 +28,15 @@ class Dr(Service, OpenGraphThumbMixin):
|
||||
links = resources['Links']
|
||||
break
|
||||
|
||||
streams = {}
|
||||
for i in links:
|
||||
if options.hls:
|
||||
if i["Target"] == "Ios":
|
||||
stream = {}
|
||||
stream["uri"] = i["Uri"]
|
||||
streams[int(i["Bitrate"])] = stream
|
||||
if i["Target"] == "Ios":
|
||||
yield HLS(options, i["Uri"], i["Bitrate"])
|
||||
else:
|
||||
if i["Target"] == "Streaming":
|
||||
stream = {}
|
||||
stream["uri"] = i["Uri"]
|
||||
streams[int(i["Bitrate"])] = stream
|
||||
options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "")
|
||||
rtmp = "rtmp://vod.dr.dk/cms/"
|
||||
yield RTMP(options, rtmp, i["Bitrate"])
|
||||
|
||||
if len(streams) == 1:
|
||||
test = streams[list(streams.keys())[0]]
|
||||
else:
|
||||
test = select_quality(options, streams)
|
||||
|
||||
if options.hls:
|
||||
download_hls(options, test["uri"])
|
||||
else:
|
||||
options.other = "-y '%s'" % test["uri"].replace("rtmp://vod.dr.dk/cms/", "")
|
||||
rtmp = "rtmp://vod.dr.dk/cms/"
|
||||
download_rtmp(options, rtmp)
|
||||
else:
|
||||
match = re.search(r'resource="([^"]*)"', data)
|
||||
if not match:
|
||||
@ -60,14 +45,8 @@ class Dr(Service, OpenGraphThumbMixin):
|
||||
resource_url = "http://www.dr.dk%s" % 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)
|
||||
|
||||
options.other = "-v -y '" + uri.replace("rtmp://vod.dr.dk/cms/", "") + "'"
|
||||
rtmp = "rtmp://vod.dr.dk/cms/"
|
||||
download_rtmp(options, rtmp)
|
||||
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'])
|
Loading…
Reference in New Issue
Block a user