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

fix some return values

This commit is contained in:
Johan Andersson 2021-12-18 20:18:25 +01:00
parent 091e84659c
commit 96544ae2f8
8 changed files with 18 additions and 16 deletions

View File

@ -74,15 +74,16 @@ class Barnkanalen(Svtplay):
yield from self._get_video(janson)
def find_all_episodes(self, config):
episodes = []
data = self.get_urldata()
match = re.search(self.info_search_expr, data)
if not match:
logging.error("Can't find video info.")
return
return episodes
janson = json.loads(match.group(1))
title = janson["query"]["titleSlug"]
episodes = []
for season in janson["props"]["pageProps"]["initialState"]["featuredTitle"]["associatedContent"]:
for episode in season["items"]:
if "variants" in episode["item"]:

View File

@ -9,4 +9,3 @@ class Discoveryplus(Service):
def get(self):
yield ServiceError("Can't download videos from this site anymore because of DRM")
return

View File

@ -89,19 +89,20 @@ class Mtvnn(Service, OpenGraphThumbMixin):
yield from hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
def find_all_episodes(self, config):
episodes = []
match = re.search(r"data-franchise='([^']+)'", self.get_urldata())
if match is None:
logging.error("Couldn't program id")
return
return episodes
programid = match.group(1)
match = re.findall(r"<li class='([a-z]+ )?playlist-item( [a-z]+)*?'( data-[-a-z]+='[^']+')* data-item-id='([^']+)'", self.get_urldata())
if not match:
logging.error("Couldn't retrieve episode list")
return
return episodes
episodNr = []
for i in match:
episodNr.append(i[3])
episodes = []
n = 0
for i in sorted(episodNr):
if n == config.get("all_last"):

View File

@ -71,6 +71,7 @@ class OppetArkiv(Service, OpenGraphThumbMixin):
return None
def find_all_episodes(self, config):
episodes = []
page = 1
data = self.get_urldata()
match = re.search(r'"/etikett/titel/([^"/]+)', data)
@ -78,9 +79,8 @@ class OppetArkiv(Service, OpenGraphThumbMixin):
match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^/]+)/', self.url)
if match is None:
logging.error("Couldn't find title")
return
return episodes
program = match.group(1)
episodes = []
n = 0
if self.config.get("all_last") > 0:
@ -111,7 +111,7 @@ class OppetArkiv(Service, OpenGraphThumbMixin):
datatitle = re.search('data-title="([^"]+)"', self.get_urldata())
if not datatitle:
return None
return
datat = decode_html_entities(datatitle.group(1))
self.output["title"] = self.name(datat)
self.seasoninfo(datat)

View File

@ -119,7 +119,7 @@ class Svtplay(Service, MetadataThumbMixin):
match = re.search(self.info_search_expr, self.get_urldata())
if not match:
logging.error("Can't find video info.")
return
return videos
janson = json.loads(match.group(1))
video_data = None
for data_entry in janson["props"]["urqlState"].values():
@ -172,6 +172,7 @@ class Svtplay(Service, MetadataThumbMixin):
def _all_episodes(self, url):
parse = urlparse(url)
tab = None
videos = []
if parse.query:
query = parse_qs(parse.query)
if "tab" in query:
@ -181,7 +182,7 @@ class Svtplay(Service, MetadataThumbMixin):
match = re.search(self.info_search_expr, data)
if not match:
logging.error("Can't find video info.")
return
return videos
janson = json.loads(match.group(1))
video_data = None
@ -195,9 +196,8 @@ class Svtplay(Service, MetadataThumbMixin):
break
collections = []
videos = []
if video_data is None:
return
return videos
if video_data["item"]["parent"]["__typename"] == "Single":
videos.append(urljoin("http://www.svtplay.se", video_data["item"]["urls"]["svtplay"]))
for i in video_data["associatedContent"]:

View File

@ -59,7 +59,7 @@ class Urplay(Service, OpenGraphThumbMixin):
match = re.search(r"__NEXT_DATA__\" type=\"application\/json\">({.+})<\/script>", self.get_urldata())
if not match:
logging.error("Can't find video info.")
return
return episodes
data = unescape(match.group(1))
jsondata = json.loads(data)

View File

@ -125,7 +125,7 @@ class Viafree(Service, OpenGraphThumbMixin):
match = re.search('}}}},("staticPages".*}}); windo', data)
if not match:
logging.error("Cant find necessary info")
return
return episodes
janson = self._jansonpage(match.group(1))
seasons = []
@ -136,7 +136,7 @@ class Viafree(Service, OpenGraphThumbMixin):
match = re.search('}}}},("staticPages".*}}); windo', data)
if not match:
logging.error("Cant find necessary info")
return
return episodes
janson = self._jansonpage(match.group(1))

View File

@ -45,6 +45,7 @@ class Options:
def get(self, key):
if key in self.default:
return self.default[key]
return None
def get_variable(self):
return self.default