1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-28 06:04:17 +01:00

services: parse hls playlist first.

This commit is contained in:
Johan Andersson 2014-04-21 21:55:39 +02:00
parent 15e8fc94b7
commit 305ecf75a8
7 changed files with 36 additions and 22 deletions

View File

@ -41,9 +41,8 @@ def _get_full_url(url, srcurl):
return returl
class HLS(VideoRetriever):
def parse(self):
data = get_http_data(self.url)
def hlsparse(url):
data = get_http_data(url)
globaldata, files = parsem3u(data)
streams = {}
@ -51,6 +50,7 @@ class HLS(VideoRetriever):
streams[i[1]["RESOLUTION"].split("x")[1]] = i[0]
return streams
class HLS(VideoRetriever):
def download(self):
if self.options.live and not self.options.force:
raise LiveHLSException(self.url)

View File

@ -8,7 +8,7 @@ import sys
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import get_http_data
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hls import HLS
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.log import log
class Dr(Service, OpenGraphThumbMixin):
@ -30,7 +30,9 @@ class Dr(Service, OpenGraphThumbMixin):
for i in links:
if i["Target"] == "Ios":
yield HLS(options, i["Uri"], i["Bitrate"])
streams = hlsparse(i["Uri"])
for n in list(streams.keys()):
yield HLS(options, streams[n], n)
else:
if i["Target"] == "Streaming":
options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "")

View File

@ -14,7 +14,7 @@ from svtplay_dl.utils.urllib import urlparse, quote
from svtplay_dl.service import Service
from svtplay_dl.utils import get_http_data
from svtplay_dl.log import log
from svtplay_dl.fetcher.hls import HLS
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.http import HTTP
class JustinException(Exception):
@ -148,4 +148,6 @@ class Justin(Service):
if not options.output:
options.output = channel
yield HLS(options, hls_url, 0)
streams = hlsparse(hls_url)
for n in list(streams.keys()):
yield HLS(options, streams[n], n)

View File

@ -9,7 +9,7 @@ from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import get_http_data
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.hds import HDS
from svtplay_dl.fetcher.hls import HLS
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.subtitle import subtitle_tt
from svtplay_dl.log import log
@ -42,7 +42,9 @@ class Nrk(Service, OpenGraphThumbMixin):
options.live = data["isLive"]
if options.hls:
manifest_url = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
yield HLS(options, manifest_url, "0")
streams = hlsparse(manifest_url)
for n in list(streams.keys()):
yield HLS(options, streams[n], n)
else:
manifest_url = "%s?hdcore=2.8.0&g=hejsan" % manifest_url
yield HDS(options, manifest_url, "0")

View File

@ -5,7 +5,7 @@ import re
from svtplay_dl.service import Service
from svtplay_dl.utils import get_http_data
from svtplay_dl.fetcher.hls import HLS
from svtplay_dl.fetcher.hls import HLS, hlsparse
class Ruv(Service):
supported_domains = ['ruv.is']
@ -18,5 +18,7 @@ class Ruv(Service):
tengipunktur = js.split('"')[1]
match = re.search(r"http.*tengipunktur [+] '([:]1935.*)'", data)
m3u8_url = "http://" + tengipunktur + match.group(1)
yield HLS(options, m3u8_url)
streams = hlsparse(m3u8_url)
for n in list(streams.keys()):
yield HLS(options, streams[n], n)

View File

@ -10,7 +10,7 @@ from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import get_http_data
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.hds import HDS
from svtplay_dl.fetcher.hls import HLS
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.subtitle import subtitle_wsrt
@ -56,7 +56,9 @@ class Svtplay(Service, OpenGraphThumbMixin):
parse = urlparse(i["url"])
if parse.path.find("m3u8") > 0:
yield HLS(options, i["url"], i["bitrate"])
streams = hlsparse(i["url"])
for n in list(streams.keys()):
yield HLS(options, streams[n], n)
elif parse.path.find("f4m") > 0:
match = re.search(r"\/se\/secure\/", i["url"])
if not match:

View File

@ -9,7 +9,7 @@ import xml.etree.ElementTree as ET
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import get_http_data
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hls import HLS
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.log import log
from svtplay_dl.subtitle import subtitle_tt
@ -41,11 +41,15 @@ class Urplay(Service, OpenGraphThumbMixin):
hls = "%s%s" % (http, jsondata["streaming_config"]["http_streaming"]["hls_file"])
rtmp = "rtmp://%s/%s" % (basedomain, jsondata["streaming_config"]["rtmp"]["application"])
path = "mp%s:%s" % (jsondata["file_flash"][-1], jsondata["file_flash"])
yield HLS(options, hls, "480")
streams = hlsparse(hls)
for n in list(streams.keys()):
yield HLS(options, streams[n], n)
options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path)
yield RTMP(options, rtmp, "480")
if hd:
yield HLS(options, hls_hd, "720")
streams = hlsparse(hls_hd)
for n in list(streams.keys()):
yield HLS(options, streams[n], n)
options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path_hd)
yield RTMP(options, rtmp, "720")