mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-23 19:55:38 +01:00
svtplay: improve detection on languages like syntolkat
This commit is contained in:
parent
5919935d50
commit
dcdf17bab4
@ -8,6 +8,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
from urllib.parse import quote_plus
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
@ -113,6 +114,33 @@ class Svtplay(Service, MetadataThumbMixin):
|
|||||||
subfix = lang
|
subfix = lang
|
||||||
yield from subtitle_probe(copy.copy(self.config), i["url"], subfix=subfix, output=self.output)
|
yield from subtitle_probe(copy.copy(self.config), i["url"], subfix=subfix, output=self.output)
|
||||||
|
|
||||||
|
if "variants" in janson and "default" in janson["variants"]:
|
||||||
|
if len(janson["variants"]["default"]["videoReferences"]) == 0:
|
||||||
|
yield ServiceError("Media doesn't have any associated videos.")
|
||||||
|
return
|
||||||
|
|
||||||
|
for videorfc in janson["variants"]["default"]["videoReferences"]:
|
||||||
|
params = {}
|
||||||
|
params["manifestUrl"] = quote_plus(videorfc["url"])
|
||||||
|
|
||||||
|
format = videorfc["format"]
|
||||||
|
if "audioDescribed" in janson["variants"] and janson["variants"]["audioDescribed"]:
|
||||||
|
for audiodesc in janson["variants"]["audioDescribed"]["videoReferences"]:
|
||||||
|
if audiodesc["format"] == format:
|
||||||
|
params["manifestUrlAudioDescription"] = audiodesc["url"]
|
||||||
|
if "signInterpreted" in janson["variants"] and janson["variants"]["signInterpreted"]:
|
||||||
|
for signinter in janson["variants"]["signInterpreted"]["videoReferences"]:
|
||||||
|
if signinter["format"] == format:
|
||||||
|
params["manifestUrlSignLanguage"] = signinter["url"]
|
||||||
|
params = _dict_to_flatstr(params)
|
||||||
|
pl_url = f"https://api.svt.se/ditto/api/v1/web?{params}"
|
||||||
|
|
||||||
|
if pl_url.find(".m3u8") > 0:
|
||||||
|
yield from hlsparse(self.config, self.http.request("get", pl_url), pl_url, output=self.output)
|
||||||
|
elif pl_url.find(".mpd") > 0:
|
||||||
|
yield from dashparse(self.config, self.http.request("get", pl_url), pl_url, output=self.output)
|
||||||
|
|
||||||
|
else:
|
||||||
if "videoReferences" in janson:
|
if "videoReferences" in janson:
|
||||||
if len(janson["videoReferences"]) == 0:
|
if len(janson["videoReferences"]) == 0:
|
||||||
yield ServiceError("Media doesn't have any associated videos.")
|
yield ServiceError("Media doesn't have any associated videos.")
|
||||||
@ -123,6 +151,7 @@ class Svtplay(Service, MetadataThumbMixin):
|
|||||||
yield from hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
|
yield from hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
|
||||||
elif i["url"].find(".mpd") > 0:
|
elif i["url"].find(".mpd") > 0:
|
||||||
yield from dashparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
|
yield from dashparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
|
||||||
|
# logging.info(json.dumps(janson["videoReferences"], indent=2))
|
||||||
|
|
||||||
def _lists(self):
|
def _lists(self):
|
||||||
videos = []
|
videos = []
|
||||||
@ -422,3 +451,10 @@ class Svtplay(Service, MetadataThumbMixin):
|
|||||||
|
|
||||||
if "description" in episode:
|
if "description" in episode:
|
||||||
self.output["episodedescription"] = episode["description"]
|
self.output["episodedescription"] = episode["description"]
|
||||||
|
|
||||||
|
|
||||||
|
def _dict_to_flatstr(flat):
|
||||||
|
text = ""
|
||||||
|
for i in flat:
|
||||||
|
text += f"{i}={flat[i]}&"
|
||||||
|
return text
|
||||||
|
Loading…
Reference in New Issue
Block a user