mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 21:54:17 +01:00
Return empty dict instead of None
This commit is contained in:
parent
f300e24ca3
commit
1a14d26b1b
@ -135,14 +135,14 @@ def dashparse(config, res, url, output=None):
|
||||
duration_sec = None
|
||||
|
||||
if not res:
|
||||
return None
|
||||
return streams
|
||||
|
||||
if res.status_code >= 400:
|
||||
streams[0] = ServiceError("Can't read DASH playlist. {0}".format(res.status_code))
|
||||
return streams
|
||||
if len(res.text) < 1:
|
||||
streams[0] = ServiceError("Can't read DASH playlist. {0}, size: {1}".format(res.status_code, len(res.text)))
|
||||
return
|
||||
return streams
|
||||
xml = ET.XML(res.text)
|
||||
|
||||
if xml.find("./{urn:mpeg:dash:schema:mpd:2011}BaseURL") is not None:
|
||||
@ -168,9 +168,7 @@ def dashparse(config, res, url, output=None):
|
||||
|
||||
if not audiofiles or not videofiles:
|
||||
streams[0] = ServiceError("Found no Audiofiles or Videofiles to download.")
|
||||
return
|
||||
|
||||
options.set("other", "mp4")
|
||||
return streams
|
||||
|
||||
for i in videofiles.keys():
|
||||
bitrate = i + list(audiofiles.keys())[0]
|
||||
|
@ -39,7 +39,7 @@ def hdsparse(config, res, manifest, output=None):
|
||||
bootstrap = {}
|
||||
|
||||
if not res:
|
||||
return None
|
||||
return streams
|
||||
|
||||
if res.status_code >= 400:
|
||||
streams[0] = ServiceError("Can't read HDS playlist. {0}".format(res.status_code))
|
||||
|
@ -35,9 +35,8 @@ class Aftonbladettv(Service):
|
||||
data = json.loads(data)
|
||||
|
||||
streams = hlsparse(self.config, self.http.request("get", data["streamUrls"]["hls"]), data["streamUrls"]["hls"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
|
||||
class Aftonbladet(Service):
|
||||
@ -89,7 +88,6 @@ class Aftonbladet(Service):
|
||||
params={"hdcore": "3.7.0"}),
|
||||
streamUrls["hds"]))
|
||||
|
||||
if streams:
|
||||
for s in streams:
|
||||
for key in list(s.keys()):
|
||||
yield s[key]
|
||||
for s in streams:
|
||||
for key in list(s.keys()):
|
||||
yield s[key]
|
||||
|
@ -37,10 +37,8 @@ class Atg(Service):
|
||||
|
||||
if "urls" in janson:
|
||||
for i in janson["urls"]:
|
||||
stream = None
|
||||
if "m3u" == i:
|
||||
stream = hlsparse(self.config, self.http.request("get", janson["urls"]["m3u"]), janson["urls"]["m3u"])
|
||||
|
||||
if stream:
|
||||
for key in list(stream.keys()):
|
||||
yield stream[key]
|
||||
|
@ -64,9 +64,8 @@ class Bigbrother(Service, OpenGraphThumbMixin):
|
||||
if i["defaultURL"].endswith("f4m"):
|
||||
streams = hdsparse(copy.copy(self.config),
|
||||
self.http.request("get", i["defaultURL"], params={"hdcore": "3.7.0"}), i["defaultURL"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
if i["defaultURL"].endswith("m3u8"):
|
||||
streams = hlsparse(self.config, self.http.request("get", i["defaultURL"]), i["defaultURL"])
|
||||
|
@ -61,9 +61,8 @@ class Cmore(Service):
|
||||
i = janson["playback"]["items"]["item"]
|
||||
if i["mediaFormat"] == "ism":
|
||||
streams = dashparse(self.config, self.http.request("get", i["url"]), i["url"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def _autoname(self, vid):
|
||||
url = "https://restapi.cmore.{0}/api/tve_web/asset/{1}.json?expand=metadata".format(self._gettld(), vid)
|
||||
|
@ -81,9 +81,8 @@ class Dplay(Service):
|
||||
return
|
||||
streams = hlsparse(self.config, self.http.request("get", res.json()["data"]["attributes"]["streaming"]["hls"]["url"]),
|
||||
res.json()["data"]["attributes"]["streaming"]["hls"]["url"], httpobject=self.http)
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def _autoname(self, jsondata):
|
||||
match = re.search('^([^/]+)/', jsondata["data"]["attributes"]["path"])
|
||||
|
@ -16,6 +16,5 @@ class Efn(Service, OpenGraphThumbMixin):
|
||||
return
|
||||
|
||||
streams = hlsparse(self.config, self.http.request("get", match.group(1)), match.group(1))
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
@ -98,6 +98,5 @@ class Eurosport(Service):
|
||||
hls_url = res.json()["stream"]["complete"]
|
||||
|
||||
streams = hlsparse(self.config, self.http.request("get", hls_url), hls_url, authorization=access_token)
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
@ -34,9 +34,8 @@ class Lemonwhale(Service):
|
||||
jdata = json.loads(data)
|
||||
if "videos" in jdata:
|
||||
streams = self.get_video(jdata)
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def get_vid(self):
|
||||
match = re.search(r'video url-([^"]+)', self.get_urldata())
|
||||
|
@ -53,10 +53,8 @@ class Mtvnn(Service, OpenGraphThumbMixin):
|
||||
|
||||
hls_url = xml.find("./video").find("item").find("rendition").find("src").text
|
||||
stream = hlsparse(self.config, self.http.request("get", hls_url), hls_url)
|
||||
if stream:
|
||||
|
||||
for key in list(stream.keys()):
|
||||
yield stream[key]
|
||||
for key in list(stream.keys()):
|
||||
yield stream[key]
|
||||
return
|
||||
|
||||
match = re.search(r'data-mrss=[\'"](http://gakusei-cluster.mtvnn.com/v2/mrss.xml[^\'"]+)[\'"]', data)
|
||||
@ -96,9 +94,8 @@ class Mtvnn(Service, OpenGraphThumbMixin):
|
||||
dataj = json.loads(data)
|
||||
for i in dataj["local_playlist_videos"]:
|
||||
streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def find_all_episodes(self, config):
|
||||
match = re.search(r"data-franchise='([^']+)'", self.get_urldata())
|
||||
|
@ -46,6 +46,5 @@ class NHL(Service, OpenGraphThumbMixin):
|
||||
janson = res.json()
|
||||
for i in janson["user_verified_event"][0]["user_verified_content"][0]["user_verified_media_item"]:
|
||||
streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
@ -55,9 +55,8 @@ class Picsearch(Service, OpenGraphThumbMixin):
|
||||
for i in jansson["media"]["playerconfig"]["playlist"]:
|
||||
if "provider" in i and i["provider"] == "httpstreaming":
|
||||
streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def get_auth(self):
|
||||
match = re.search(r"picsearch_ajax_auth[ ]*=[ ]*['\"]([^'\"]+)['\"]", self.get_urldata())
|
||||
|
@ -30,6 +30,5 @@ class Riksdagen(Service, OpenGraphThumbMixin):
|
||||
if i["mimetype"] == "application/x-mpegurl":
|
||||
data2 = self.http.get(i["url"]).json()
|
||||
streams = hlsparse(self.config, self.http.request("get", data2["url"]), data2["url"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
@ -67,6 +67,5 @@ class Sportlib(Service, OpenGraphThumbMixin):
|
||||
res = self.http.post("https://playlist.oz.com/cookie", json=postjson)
|
||||
cookies = res.cookies
|
||||
streams = hlsparse(self.config, self.http.request("get", hlsplaylist), hlsplaylist, keycookie=cookies)
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
@ -33,10 +33,9 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
||||
|
||||
self.config.set("live", True)
|
||||
self.options.hls_time_stamp = True
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
streams = hlsparse(self.config, self.http.request("get", url), url)
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
return
|
||||
|
||||
data = self.get_urldata()
|
||||
@ -110,10 +109,9 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
||||
if i.find("mediaFormat").text == "mp4":
|
||||
parse = urlparse(i.find("url").text)
|
||||
if parse.path.endswith("m3u8"):
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
streams = hlsparse(self.config, self.http.request("get", i.find("url").text), i.find("url").text)
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def _get_show_info(self):
|
||||
show = self._get_showname()
|
||||
|
@ -31,9 +31,8 @@ class Vg(Service, OpenGraphThumbMixin):
|
||||
if "hds" in jsondata["streamUrls"]:
|
||||
streams = hdsparse(self.config, 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]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
if "hls" in jsondata["streamUrls"]:
|
||||
streams = hlsparse(self.config, self.http.request("get", jsondata["streamUrls"]["hls"]), jsondata["streamUrls"]["hls"])
|
||||
for n in list(streams.keys()):
|
||||
|
@ -164,9 +164,8 @@ class Viaplay(Service, OpenGraphThumbMixin):
|
||||
filename = streamj["streams"]["medium"]
|
||||
if ".f4m" in filename:
|
||||
streams = hdsparse(self.config, self.http.request("get", filename, params={"hdcore": "3.7.0"}), filename)
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
else:
|
||||
parse = urlparse(filename)
|
||||
match = re.search("^(/[^/]+)/(.*)", parse.path)
|
||||
@ -180,9 +179,8 @@ class Viaplay(Service, OpenGraphThumbMixin):
|
||||
|
||||
if streamj["streams"]["hls"]:
|
||||
streams = hlsparse(self.config, self.http.request("get", streamj["streams"]["hls"]), streamj["streams"]["hls"])
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
||||
def find_all_episodes(self, options):
|
||||
seasons = []
|
||||
|
@ -26,6 +26,5 @@ class Viasatsport(Service, OpenGraphThumbMixin):
|
||||
if re.search("/live/", hls):
|
||||
self.config.set("live", True)
|
||||
streams = hlsparse(self.config, self.http.request("get", hls), hls)
|
||||
if streams:
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
for n in list(streams.keys()):
|
||||
yield streams[n]
|
||||
|
Loading…
Reference in New Issue
Block a user