1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

reorder arguments for hlsparse and hdsparse

This commit is contained in:
Johan Andersson 2015-10-04 14:37:16 +02:00
parent 39f7d4ba2e
commit fa05480327
19 changed files with 66 additions and 70 deletions

View File

@ -3,12 +3,11 @@
from __future__ import absolute_import
import re
import json
import copy
from svtplay_dl.service import Service
from svtplay_dl.utils import decode_html_entities
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
class Aftonbladet(Service):
@ -65,7 +64,7 @@ class Aftonbladet(Service):
else:
plist = "http://%s/%s/%s" % (address, path, hls["filename"])
streams = hlsparse(plist, self.http.request("get", plist).text)
streams = hlsparse(options, self.http.request("get", plist), plist)
if streams:
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -8,7 +8,7 @@ import copy
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hds import hdsparse
from svtplay_dl.fetcher.hls import hlsparse, HLS
from svtplay_dl.fetcher.hls import hlsparse
class Bigbrother(Service, OpenGraphThumbMixin):
@ -55,12 +55,12 @@ class Bigbrother(Service, OpenGraphThumbMixin):
renditions = jsondata["data"]["programmedContent"]["videoPlayer"]["mediaDTO"]["renditions"]
for i in renditions:
if i["defaultURL"].endswith("f4m"):
streams = hdsparse(copy.copy(options), self.http.request("get", i["defaultURL"], params={"hdcore": "3.7.0"}).text, i["defaultURL"])
streams = hdsparse(copy.copy(options), self.http.request("get", i["defaultURL"], params={"hdcore": "3.7.0"}), i["defaultURL"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if i["defaultURL"].endswith("m3u8"):
streams = hlsparse(i["defaultURL"], self.http.request("get", i["defaultURL"]).text)
streams = hlsparse(options, self.http.request("get", i["defaultURL"]), i["defaultURL"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -6,7 +6,7 @@ import copy
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.error import ServiceError
@ -31,9 +31,9 @@ class Dbtv(Service, OpenGraphThumbMixin):
for i in playlist:
if i["brightcoveId"] == vidoid:
if i["HLSURL"]:
streams = hlsparse(i["HLSURL"], self.http.request("get", i["HLSURL"]).text)
streams = hlsparse(options, self.http.request("get", i["HLSURL"]), i["HLSURL"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
for n in i["renditions"]:
if n["container"] == "MP4":
yield HTTP(copy.copy(options), n["URL"], int(n["rate"])/1000)

View File

@ -10,7 +10,7 @@ import os
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import filenamify
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.error import ServiceError
@ -103,6 +103,6 @@ class Disney(Service, OpenGraphThumbMixin):
url = "http://cdnapi.kaltura.com/p/%s/sp/%s00/playManifest/entryId/%s/format/applehttp/protocol/http/a.m3u8?ks=%s&referrer=aHR0cDovL3d3dy5kaXNuZXkuc2U=&" % (partnerid[1:], partnerid[1:], entryid, ks)
redirect = self.http.check_redirect(url)
streams = hlsparse(redirect, self.http.request("get", redirect).text)
streams = hlsparse(options, self.http.request("get", redirect), redirect)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -7,7 +7,7 @@ import copy
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.hds import hdsparse
from svtplay_dl.subtitle import subtitle
from svtplay_dl.error import ServiceError
@ -51,14 +51,14 @@ class Dr(Service, OpenGraphThumbMixin):
else:
for stream in resource['Links']:
if stream["Target"] == "HDS":
streams = hdsparse(copy.copy(options), self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}).text, stream["Uri"])
streams = hdsparse(copy.copy(options), self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}), stream["Uri"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if stream["Target"] == "HLS":
streams = hlsparse(stream["Uri"], self.http.request("get", stream["Uri"]).text)
streams = hlsparse(options, self.http.request("get", stream["Uri"]), stream["Uri"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
if stream["Target"] == "Streaming":
options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")
rtmp = "rtmp://vod.dr.dk/cms/"
@ -73,9 +73,9 @@ class Dr(Service, OpenGraphThumbMixin):
break
for i in links:
if i["Target"] == "Ios" or i["Target"] == "HLS":
streams = hlsparse(i["Uri"], self.http.request("get", i["Uri"]).text)
streams = hlsparse(options, self.http.request("get", i["Uri"]), i["Uri"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
else:
if i["Target"] == "Streaming":
options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "")

View File

@ -1,9 +1,8 @@
from __future__ import absolute_import
import re
import copy
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.error import ServiceError
@ -18,7 +17,7 @@ class Efn(Service, OpenGraphThumbMixin):
yield ServiceError("Cant find video info")
return
streams = hlsparse(match.group(1), self.http.request("get", match.group(1)).text)
streams = hlsparse(options, self.http.request("get", match.group(1)), match.group(1))
if streams:
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -8,7 +8,7 @@ import xml.etree.ElementTree as ET
from svtplay_dl.service import Service
from svtplay_dl.error import ServiceError
from svtplay_dl.log import log
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.utils import is_py2_old
from svtplay_dl.utils.urllib import unquote_plus
@ -56,6 +56,6 @@ class Expressen(Service):
yield RTMP(options2, filename, int(i.attrib["bitrate"]))
ipadurl = xml.find("mobileurls").find("ipadurl").text
streams = hlsparse(ipadurl, self.http.request("get", ipadurl).text)
streams = hlsparse(options, self.http.request("get", ipadurl), ipadurl)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -10,7 +10,7 @@ from svtplay_dl.service import Service
from svtplay_dl.utils import filenamify
from svtplay_dl.log import log
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.subtitle import subtitle
from svtplay_dl.error import ServiceError
@ -95,9 +95,9 @@ class Kanal5(Service):
show = False
if "streams" in data.keys():
for i in data["streams"]:
streams = hlsparse(i["source"], self.http.request("get", i["source"]).text)
streams = hlsparse(options, self.http.request("get", i["source"]), i["source"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
if "reasonsForNoStreams" in data and show:
yield ServiceError(data["reasonsForNoStreams"][0])

View File

@ -8,7 +8,7 @@ import copy
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.hds import hdsparse
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.subtitle import subtitle
from svtplay_dl.error import ServiceError
@ -55,11 +55,11 @@ class Nrk(Service, OpenGraphThumbMixin):
if data.status_code == 403:
yield ServiceError("Can't fetch the video because of geoblocked")
return
streams = hlsparse(hlsurl, data.text)
streams = hlsparse(options, data, hlsurl)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
streams = hdsparse(copy.copy(options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}).text, manifest_url)
streams = hdsparse(copy.copy(options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url)
if streams:
for n in list(streams.keys()):
yield streams[n]

View File

@ -50,7 +50,7 @@ class Picsearch(Service, OpenGraphThumbMixin):
if "live" in playlist:
options.live = playlist["live"]
if playlist["url"].endswith(".f4m"):
streams = hdsparse(copy.copy(options), self.http.request("get", playlist["url"], params={"hdcore": "3.7.0"}).text, playlist["url"])
streams = hdsparse(options, self.http.request("get", playlist["url"], params={"hdcore": "3.7.0"}), playlist["url"])
if streams:
for n in list(streams.keys()):
yield streams[n]

View File

@ -4,7 +4,7 @@ import os
from svtplay_dl.service import Service
from svtplay_dl.fetcher.hds import hdsparse
from svtplay_dl.fetcher.hls import hlsparse, HLS
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.log import log
@ -28,14 +28,14 @@ class Raw(Service):
if extention:
options.output = "%s.flv" % options.output
streams = hdsparse(copy.copy(options), self.http.request("get", self.url, params={"hdcore": "3.7.0"}).text, self.url)
streams = hdsparse(options, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url)
if streams:
for n in list(streams.keys()):
yield streams[n]
if self.url.find(".m3u8") > 0:
streams = hlsparse(self.url, self.http.request("get", self.url).text)
streams = hlsparse(options, self.http.request("get", self.url), self.url)
if extention:
options.output = "%s.ts" % options.output
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -28,9 +28,9 @@ class Ruv(Service):
if match:
janson = json.loads(match.group(1))
options.live = checklive(janson["result"][1])
streams = hlsparse(janson["result"][1], self.http.request("get", janson["result"][1]).text)
streams = hlsparse(options, self.http.request("get", janson["result"][1]), janson["result"][1])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
else:
yield ServiceError("Can't find json info")
else:

View File

@ -2,10 +2,9 @@
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import
import re
import copy
from svtplay_dl.service import Service
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.error import ServiceError
@ -25,9 +24,9 @@ class Solidtango(Service):
match = re.search('html5_source: "([^"]+)"', data)
if match:
streams = hlsparse(match.group(1), self.http.request("get", match.group(1)).text)
streams = hlsparse(options, self.http.request("get", match.group(1)), match.group(1))
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
else:
yield ServiceError("Can't find video info. if there is a video on the page. its a bug.")
return

View File

@ -10,7 +10,7 @@ from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import filenamify, ensure_unicode
from svtplay_dl.utils.urllib import urlparse, urljoin
from svtplay_dl.fetcher.hds import hdsparse
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.subtitle import subtitle
@ -79,15 +79,14 @@ class Svtplay(Service, OpenGraphThumbMixin):
parse = urlparse(i["url"])
if parse.path.find("m3u8") > 0:
streams = hlsparse(i["url"], self.http.request("get", i["url"]).text)
streams = hlsparse(options, self.http.request("get", i["url"]), i["url"])
if streams:
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
elif parse.path.find("f4m") > 0:
match = re.search(r"\/se\/secure\/", i["url"])
if not match:
res = self.http.request("get", i["url"], params={"hdcore": "3.7.0"})
streams = hdsparse(copy.copy(options), res.text, i["url"])
streams = hdsparse(options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"])
if streams:
for n in list(streams.keys()):
yield streams[n]

View File

@ -11,7 +11,7 @@ from svtplay_dl.utils.urllib import urlparse, parse_qs, quote_plus
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils import is_py2_old, filenamify
from svtplay_dl.log import log
from svtplay_dl.fetcher.hls import hlsparse, HLS
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hds import hdsparse
from svtplay_dl.subtitle import subtitle
@ -100,7 +100,7 @@ class Tv4play(Service, OpenGraphThumbMixin):
options.other = "-W %s -y %s" % (swf, i.find("url").text)
yield RTMP(copy.copy(options), i.find("base").text, i.find("bitrate").text)
elif parse.path[len(parse.path)-3:len(parse.path)] == "f4m":
streams = hdsparse(copy.copy(options), self.http.request("get", i.find("url").text, params={"hdcore": "3.7.0"}).text, i.find("url").text)
streams = hdsparse(options, self.http.request("get", i.find("url").text, params={"hdcore": "3.7.0"}), i.find("url").text)
if streams:
for n in list(streams.keys()):
yield streams[n]
@ -119,9 +119,9 @@ class Tv4play(Service, OpenGraphThumbMixin):
if i.find("mediaFormat").text == "mp4":
parse = urlparse(i.find("url").text)
if parse.path.endswith("m3u8"):
streams = hlsparse(i.find("url").text, self.http.request("get", i.find("url").text).text)
streams = hlsparse(options, self.http.request("get", i.find("url").text), i.find("url").text)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
def find_all_episodes(self, options):
parse = urlparse(self.url)

View File

@ -14,7 +14,7 @@ from svtplay_dl.utils.urllib import urlparse, quote_plus
from svtplay_dl.service import Service
from svtplay_dl.utils import filenamify
from svtplay_dl.log import log
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.error import ServiceError
@ -91,10 +91,10 @@ class Twitch(Service):
url = "http://usher.twitch.tv/vod/%s?nauth=%s&nauthsig=%s" % (
videoid, nauth, authsig)
streams = hlsparse(url, self.http.request("get", url).text)
streams = hlsparse(options, self.http.request("get", url), url)
if streams:
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
def _get_archive(self, options, vid):
try:
@ -162,6 +162,6 @@ class Twitch(Service):
if data.status_code == 404:
yield ServiceError("Stream is not online.")
return
streams = hlsparse(hls_url, data.text)
streams = hlsparse(options, data, hls_url)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]

View File

@ -9,7 +9,7 @@ import xml.etree.ElementTree as ET
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils.urllib import urljoin
from svtplay_dl.fetcher.rtmp import RTMP
from svtplay_dl.fetcher.hls import HLS, hlsparse
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.log import log
from svtplay_dl.error import ServiceError
from svtplay_dl.subtitle import subtitle
@ -51,15 +51,15 @@ class Urplay(Service, OpenGraphThumbMixin):
rtmp = "rtmp://%s/%s" % (basedomain, jsondata["streaming_config"]["rtmp"]["application"])
match = re.search("(mp[34]:.*$)", jsondata["file_rtmp"])
path = match.group(1)
streams = hlsparse(hls, self.http.request("get", hls).text)
streams = hlsparse(options, self.http.request("get", hls), hls)
for n in list(streams.keys()):
yield HLS(options, streams[n], n)
yield streams[n]
options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path)
yield RTMP(options, rtmp, "480")
if hd:
streams = hlsparse(hls_hd, self.http.request("get", hls_hd).text)
streams = hlsparse(options, self.http.request("get", hls_hd), hls_hd)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path_hd)
yield RTMP(copy.copy(options), rtmp, "720")

View File

@ -43,13 +43,13 @@ class Vg(Service, OpenGraphThumbMixin):
return
if "hds" in jsondata["streamUrls"]:
streams = hdsparse(copy.copy(options), self.http.request("get", jsondata["streamUrls"]["hds"], params={"hdcore": "3.7.0"}).text, jsondata["streamUrls"]["hds"])
streams = hdsparse(options, self.http.request("get", jsondata["streamUrls"]["hds"], params={"hdcore": "3.7.0"}), jsondata["streamUrls"]["hds"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if "hls" in jsondata["streamUrls"]:
streams = hlsparse(jsondata["streamUrls"]["hls"], self.http.request("get", jsondata["streamUrls"]["hls"]).text)
streams = hlsparse(options, self.http.request("get", jsondata["streamUrls"]["hls"]), jsondata["streamUrls"]["hls"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
if "mp4" in jsondata["streamUrls"]:
yield HTTP(copy.copy(options), jsondata["streamUrls"]["mp4"])

View File

@ -96,7 +96,7 @@ class Viaplay(Service, OpenGraphThumbMixin):
if streamj["streams"]["medium"]:
filename = streamj["streams"]["medium"]
if ".f4m" in filename:
streams = hdsparse(copy.copy(options), self.http.request("get", filename, params={"hdcore": "3.7.0"}).text, filename)
streams = hdsparse(options, self.http.request("get", filename, params={"hdcore": "3.7.0"}), filename)
if streams:
for n in list(streams.keys()):
yield streams[n]
@ -112,10 +112,10 @@ class Viaplay(Service, OpenGraphThumbMixin):
yield RTMP(copy.copy(options), filename, 800)
if streamj["streams"]["hls"]:
streams = hlsparse(streamj["streams"]["hls"], self.http.request("get", streamj["streams"]["hls"]).text)
streams = hlsparse(options, self.http.request("get", streamj["streams"]["hls"]), streamj["streams"]["hls"])
if streams:
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
yield streams[n]
def find_all_episodes(self, options):
format_id = re.search(r'data-format-id="(\d+)"', self.get_urldata())