2013-03-02 21:26:28 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2014-06-07 20:43:40 +02:00
|
|
|
import copy
|
2019-09-08 00:11:16 +02:00
|
|
|
import datetime
|
2019-08-25 00:27:31 +02:00
|
|
|
import hashlib
|
|
|
|
import json
|
2018-11-18 12:47:19 +01:00
|
|
|
import logging
|
2019-08-25 00:40:39 +02:00
|
|
|
import re
|
2019-09-08 00:11:16 +02:00
|
|
|
import time
|
2018-02-26 00:06:06 +01:00
|
|
|
from operator import itemgetter
|
2019-08-25 00:40:39 +02:00
|
|
|
from urllib.parse import parse_qs
|
|
|
|
from urllib.parse import urljoin
|
|
|
|
from urllib.parse import urlparse
|
2015-12-27 20:55:10 +01:00
|
|
|
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2016-03-26 21:38:31 +01:00
|
|
|
from svtplay_dl.fetcher.dash import dashparse
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
|
|
|
from svtplay_dl.service import MetadataThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
2014-08-31 01:20:36 +02:00
|
|
|
from svtplay_dl.subtitle import subtitle
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.utils.text import filenamify
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2019-09-06 14:42:38 +02:00
|
|
|
URL_VIDEO_API = "https://api.svt.se/video/"
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2018-01-30 20:11:37 +01:00
|
|
|
|
2018-07-30 12:52:05 +02:00
|
|
|
class Svtplay(Service, MetadataThumbMixin):
|
2019-08-25 00:27:31 +02:00
|
|
|
supported_domains = ["svtplay.se", "svt.se", "beta.svtplay.se", "svtflow.se"]
|
2021-02-07 12:35:18 +01:00
|
|
|
info_search_expr = r"<script id=\"__NEXT_DATA__\" type=\"application\/json\">({.+})<\/script>"
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2015-12-27 14:40:27 +01:00
|
|
|
parse = urlparse(self.url)
|
2015-12-28 11:41:15 +01:00
|
|
|
if parse.netloc == "www.svtplay.se" or parse.netloc == "svtplay.se":
|
2019-09-06 22:49:49 +02:00
|
|
|
if parse.path[:6] != "/video" and parse.path[:6] != "/klipp" and parse.path[:8] != "/kanaler":
|
|
|
|
yield ServiceError("This mode is not supported anymore. Need the url with the video.")
|
2015-12-27 14:40:27 +01:00
|
|
|
return
|
2016-01-10 15:33:30 +01:00
|
|
|
|
2017-02-21 00:00:30 +01:00
|
|
|
query = parse_qs(parse.query)
|
|
|
|
self.access = None
|
|
|
|
if "accessService" in query:
|
|
|
|
self.access = query["accessService"]
|
|
|
|
|
2019-08-31 14:30:52 +02:00
|
|
|
urldata = self.get_urldata()
|
|
|
|
|
2018-01-07 20:52:19 +01:00
|
|
|
if parse.path[:8] == "/kanaler":
|
2020-12-12 21:44:24 +01:00
|
|
|
ch = "ch-{}".format(parse.path[parse.path.rfind("/") + 1 :])
|
|
|
|
_url = urljoin(URL_VIDEO_API, ch)
|
2019-08-31 14:30:52 +02:00
|
|
|
res = self.http.get(_url)
|
2018-01-07 20:52:19 +01:00
|
|
|
try:
|
|
|
|
janson = res.json()
|
|
|
|
except json.decoder.JSONDecodeError:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield ServiceError("Can't decode api request: {}".format(res.request.url))
|
2018-01-07 20:52:19 +01:00
|
|
|
return
|
|
|
|
videos = self._get_video(janson)
|
2018-05-08 22:46:11 +02:00
|
|
|
self.config.set("live", True)
|
2019-08-25 00:33:51 +02:00
|
|
|
yield from videos
|
2018-01-07 20:52:19 +01:00
|
|
|
return
|
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
match = re.search(self.info_search_expr, urldata)
|
2019-09-06 14:42:38 +02:00
|
|
|
if not match:
|
|
|
|
yield ServiceError("Can't find video info.")
|
2017-02-18 18:28:03 +01:00
|
|
|
return
|
|
|
|
|
2019-09-06 14:42:38 +02:00
|
|
|
janson = json.loads(match.group(1))
|
2021-02-07 12:35:18 +01:00
|
|
|
video_data = None
|
|
|
|
vid = None
|
|
|
|
for data_entry in janson["props"]["urqlState"].values():
|
|
|
|
entry = json.loads(data_entry["data"])
|
|
|
|
for key, data in entry.items():
|
|
|
|
if key == "listablesByEscenicId" and "videoSvtId" in data[0]:
|
|
|
|
video_data = data[0]
|
|
|
|
vid = video_data["videoSvtId"]
|
|
|
|
break
|
|
|
|
# if video_data:
|
|
|
|
# break
|
|
|
|
|
|
|
|
if not vid and not self.visibleid:
|
2019-09-07 12:30:49 +02:00
|
|
|
yield ServiceError("Can't find video id")
|
|
|
|
return
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
self.outputfilename(video_data)
|
|
|
|
self.extrametadata(video_data)
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2018-01-07 20:52:19 +01:00
|
|
|
res = self.http.get(URL_VIDEO_API + vid)
|
2017-10-03 21:07:26 +02:00
|
|
|
try:
|
|
|
|
janson = res.json()
|
|
|
|
except json.decoder.JSONDecodeError:
|
2019-08-25 00:33:51 +02:00
|
|
|
yield ServiceError("Can't decode api request: {}".format(res.request.url))
|
2017-10-03 21:07:26 +02:00
|
|
|
return
|
2017-05-08 00:14:05 +02:00
|
|
|
videos = self._get_video(janson)
|
2019-08-25 00:33:51 +02:00
|
|
|
yield from videos
|
2017-05-08 00:14:05 +02:00
|
|
|
|
|
|
|
def _get_video(self, janson):
|
2017-01-27 02:10:46 +01:00
|
|
|
if "subtitleReferences" in janson:
|
|
|
|
for i in janson["subtitleReferences"]:
|
2020-01-29 20:44:32 +01:00
|
|
|
if i["format"] == "webvtt" and "url" in i:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield subtitle(copy.copy(self.config), "wrst", i["url"], output=self.output)
|
2017-01-27 02:10:46 +01:00
|
|
|
|
2017-01-26 21:54:58 +01:00
|
|
|
if "videoReferences" in janson:
|
|
|
|
if len(janson["videoReferences"]) == 0:
|
2017-09-26 19:58:16 +02:00
|
|
|
yield ServiceError("Media doesn't have any associated videos.")
|
2016-11-06 19:48:22 +01:00
|
|
|
return
|
2015-10-25 15:44:47 +01:00
|
|
|
|
2017-01-26 21:54:58 +01:00
|
|
|
for i in janson["videoReferences"]:
|
2017-09-26 21:17:47 +02:00
|
|
|
streams = None
|
|
|
|
alt_streams = None
|
2017-09-26 21:56:04 +02:00
|
|
|
alt = None
|
|
|
|
query = parse_qs(urlparse(i["url"]).query)
|
|
|
|
if "alt" in query and len(query["alt"]) > 0:
|
|
|
|
alt = self.http.get(query["alt"][0])
|
|
|
|
|
2020-07-28 21:27:52 +02:00
|
|
|
if i["format"][:3] == "hls":
|
2019-09-06 22:49:49 +02:00
|
|
|
streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
|
2017-09-26 21:56:04 +02:00
|
|
|
if alt:
|
2019-09-06 22:49:49 +02:00
|
|
|
alt_streams = hlsparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output)
|
2020-07-28 21:27:52 +02:00
|
|
|
elif i["format"][:4] == "dash":
|
2019-09-06 22:49:49 +02:00
|
|
|
streams = dashparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
|
2017-09-26 21:56:04 +02:00
|
|
|
if alt:
|
2019-09-06 22:49:49 +02:00
|
|
|
alt_streams = dashparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output)
|
2017-09-26 21:17:47 +02:00
|
|
|
|
|
|
|
if streams:
|
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield streams[n]
|
|
|
|
if alt_streams:
|
|
|
|
for n in list(alt_streams.keys()):
|
|
|
|
yield alt_streams[n]
|
2016-09-10 17:30:04 +02:00
|
|
|
|
2019-09-07 12:30:49 +02:00
|
|
|
def _get_visibleid(self, janson):
|
|
|
|
esceni = None
|
2021-02-07 12:35:18 +01:00
|
|
|
for data_entry in janson["props"]["urqlState"].values():
|
|
|
|
entry = json.loads(data_entry["data"])
|
|
|
|
for key in entry.keys():
|
|
|
|
if "listablesBy" in key:
|
|
|
|
esceni = entry[key]
|
|
|
|
break
|
|
|
|
if esceni:
|
2019-09-07 12:30:49 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
if esceni:
|
2020-07-28 21:27:52 +02:00
|
|
|
try:
|
2021-02-07 12:35:18 +01:00
|
|
|
return esceni[0]["id"]
|
2020-07-28 21:27:52 +02:00
|
|
|
except IndexError:
|
|
|
|
return None
|
2019-09-07 12:30:49 +02:00
|
|
|
else:
|
|
|
|
return esceni
|
|
|
|
|
2016-08-20 13:52:19 +02:00
|
|
|
def _last_chance(self, videos, page, maxpage=2):
|
|
|
|
if page > maxpage:
|
|
|
|
return videos
|
|
|
|
|
2017-09-26 20:11:39 +02:00
|
|
|
res = self.http.get("http://www.svtplay.se/sista-chansen?sida={}".format(page))
|
2016-10-31 19:14:29 +01:00
|
|
|
match = re.search("__svtplay'] = ({.*});", res.text)
|
2016-08-20 13:52:19 +02:00
|
|
|
if not match:
|
|
|
|
return videos
|
|
|
|
|
|
|
|
dataj = json.loads(match.group(1))
|
2016-09-15 08:53:49 +02:00
|
|
|
pages = dataj["gridPage"]["pagination"]["totalPages"]
|
2016-08-20 13:52:19 +02:00
|
|
|
|
2017-09-26 19:58:16 +02:00
|
|
|
for i in dataj["gridPage"]["content"]:
|
2016-08-20 13:52:19 +02:00
|
|
|
videos.append(i["contentUrl"])
|
|
|
|
page += 1
|
2019-09-06 14:42:38 +02:00
|
|
|
videos.extend(self._last_chance(videos, page, pages))
|
2016-08-20 13:52:19 +02:00
|
|
|
return videos
|
|
|
|
|
2016-08-20 15:51:58 +02:00
|
|
|
def _genre(self, jansson):
|
|
|
|
videos = []
|
2017-02-06 13:12:33 +01:00
|
|
|
parse = urlparse(self._url)
|
2017-02-15 23:15:50 +01:00
|
|
|
dataj = jansson["clusterPage"]
|
|
|
|
tab = re.search("tab=(.+)", parse.query)
|
2017-02-15 00:47:36 +01:00
|
|
|
if tab:
|
2017-02-06 13:12:33 +01:00
|
|
|
tab = tab.group(1)
|
|
|
|
for i in dataj["tabs"]:
|
|
|
|
if i["slug"] == tab:
|
2017-02-15 00:47:36 +01:00
|
|
|
videos = self.videos_to_list(i["content"], videos)
|
|
|
|
else:
|
|
|
|
videos = self.videos_to_list(dataj["clips"], videos)
|
|
|
|
|
2016-08-20 15:51:58 +02:00
|
|
|
return videos
|
2016-08-20 13:52:19 +02:00
|
|
|
|
2018-05-13 13:06:45 +02:00
|
|
|
def find_all_episodes(self, config):
|
2016-08-20 13:52:19 +02:00
|
|
|
parse = urlparse(self._url)
|
2017-05-07 14:47:15 +02:00
|
|
|
|
2018-01-09 14:37:11 +01:00
|
|
|
videos = []
|
2017-04-12 21:23:56 +02:00
|
|
|
tab = None
|
2019-09-06 14:42:38 +02:00
|
|
|
if parse.query:
|
|
|
|
query = parse_qs(parse.query)
|
|
|
|
if "tab" in query:
|
|
|
|
tab = query["tab"][0]
|
|
|
|
|
2018-01-09 14:37:11 +01:00
|
|
|
if re.search("sista-chansen", parse.path):
|
|
|
|
videos = self._last_chance(videos, 1)
|
2017-04-12 21:23:56 +02:00
|
|
|
else:
|
2021-02-07 12:35:18 +01:00
|
|
|
match = re.search(self.info_search_expr, self.get_urldata())
|
2019-09-06 14:42:38 +02:00
|
|
|
if not match:
|
|
|
|
logging.error("Can't find video info.")
|
2019-09-07 12:30:49 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
janson = json.loads(match.group(1))
|
|
|
|
self.visibleid = self._get_visibleid(janson)
|
|
|
|
if not self.visibleid:
|
2020-11-02 23:08:56 +01:00
|
|
|
logging.error("Can't find video id. removed?")
|
2019-09-07 12:30:49 +02:00
|
|
|
return
|
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
match = re.search(self.info_search_expr, self.get_urldata())
|
2019-09-06 14:42:38 +02:00
|
|
|
if not match:
|
|
|
|
logging.error("Can't find video info.")
|
|
|
|
return videos
|
|
|
|
janson = json.loads(match.group(1))
|
2021-02-07 12:35:18 +01:00
|
|
|
associatedContent = None
|
|
|
|
|
|
|
|
for json_entry in janson["props"]["urqlState"].values():
|
|
|
|
entry = json.loads(json_entry["data"])
|
|
|
|
for key, data in entry.items():
|
2021-02-14 19:12:50 +01:00
|
|
|
if "listablesBy" in key and (len(data[0]["associatedContent"]) == 0 or data[0]["associatedContent"][0]["id"] != "related"):
|
2021-02-07 12:35:18 +01:00
|
|
|
associatedContent = data[0]["associatedContent"]
|
|
|
|
break
|
|
|
|
if associatedContent:
|
|
|
|
break
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
collections = []
|
2019-09-06 14:42:38 +02:00
|
|
|
videos = []
|
|
|
|
for i in associatedContent:
|
|
|
|
if tab:
|
2021-02-07 12:35:18 +01:00
|
|
|
if tab == i["id"]:
|
|
|
|
collections.append(i)
|
2019-09-06 14:42:38 +02:00
|
|
|
else:
|
2021-02-07 12:35:18 +01:00
|
|
|
if i["id"] == "upcoming":
|
2019-09-06 14:42:38 +02:00
|
|
|
continue
|
2021-02-07 12:35:18 +01:00
|
|
|
elif self.config.get("include_clips") and "clips" in i["id"]:
|
|
|
|
collections.append(i)
|
|
|
|
elif "clips" not in i["id"]:
|
|
|
|
collections.append(i)
|
|
|
|
|
|
|
|
if not collections:
|
|
|
|
logging.error("Can't find other episodes.")
|
|
|
|
|
|
|
|
for i in collections:
|
|
|
|
for epi in i["items"]:
|
|
|
|
if "variants" in epi["item"]:
|
|
|
|
for variant in epi["item"]["variants"]:
|
|
|
|
if variant["urls"]["svtplay"] not in videos:
|
|
|
|
videos.append(variant["urls"]["svtplay"])
|
|
|
|
if epi["item"]["urls"]["svtplay"] not in videos:
|
|
|
|
videos.append(epi["item"]["urls"]["svtplay"])
|
2018-01-09 14:37:11 +01:00
|
|
|
|
|
|
|
episodes = [urljoin("http://www.svtplay.se", x) for x in videos]
|
2017-05-07 15:02:55 +02:00
|
|
|
|
2018-05-13 13:06:45 +02:00
|
|
|
if config.get("all_last") > 0:
|
2019-08-25 00:27:31 +02:00
|
|
|
return episodes[-config.get("all_last") :]
|
2018-01-09 14:34:20 +01:00
|
|
|
return episodes
|
2014-12-28 13:57:50 +01:00
|
|
|
|
2017-02-15 00:40:25 +01:00
|
|
|
def videos_to_list(self, lvideos, videos):
|
2018-02-22 04:12:52 +01:00
|
|
|
if "episodeNumber" in lvideos[0] and lvideos[0]["episodeNumber"]:
|
2019-08-25 00:27:31 +02:00
|
|
|
lvideos = sorted(lvideos, key=itemgetter("episodeNumber"))
|
2017-02-15 00:40:25 +01:00
|
|
|
for n in lvideos:
|
|
|
|
parse = urlparse(n["contentUrl"])
|
|
|
|
if parse.path not in videos:
|
2018-05-13 13:06:45 +02:00
|
|
|
videos.append(parse.path)
|
2017-02-21 00:00:30 +01:00
|
|
|
if "versions" in n:
|
|
|
|
for i in n["versions"]:
|
|
|
|
parse = urlparse(i["contentUrl"])
|
2018-05-13 13:06:45 +02:00
|
|
|
if parse.path not in videos:
|
2017-02-21 00:00:30 +01:00
|
|
|
videos.append(parse.path)
|
|
|
|
|
2017-02-15 00:40:25 +01:00
|
|
|
return videos
|
|
|
|
|
2018-05-13 13:06:45 +02:00
|
|
|
def outputfilename(self, data):
|
2017-02-01 13:19:59 +01:00
|
|
|
name = None
|
2018-05-13 13:06:45 +02:00
|
|
|
desc = None
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
name = data["parent"]["slug"]
|
|
|
|
other = data["slug"]
|
|
|
|
vid = data["id"]
|
2018-01-13 20:27:40 +01:00
|
|
|
id = hashlib.sha256(vid.encode("utf-8")).hexdigest()[:7]
|
2015-12-27 14:40:27 +01:00
|
|
|
|
2016-01-03 02:42:32 +01:00
|
|
|
if name == other:
|
|
|
|
other = None
|
2017-02-15 23:15:50 +01:00
|
|
|
elif name is None:
|
2017-01-26 21:54:58 +01:00
|
|
|
name = other
|
|
|
|
other = None
|
2018-05-13 13:06:45 +02:00
|
|
|
|
|
|
|
season, episode = self.seasoninfo(data)
|
2021-02-07 12:35:18 +01:00
|
|
|
if "accessibility" in data:
|
|
|
|
if data["accessibility"] == "AudioDescribed":
|
2018-05-13 13:06:45 +02:00
|
|
|
desc = "syntolkat"
|
2021-02-07 12:35:18 +01:00
|
|
|
if data["accessibility"] == "SignInterpreted":
|
2018-05-13 13:06:45 +02:00
|
|
|
desc = "teckentolkat"
|
|
|
|
|
|
|
|
if not other:
|
|
|
|
other = desc
|
2018-05-12 15:42:05 +02:00
|
|
|
elif desc:
|
2018-05-13 13:06:45 +02:00
|
|
|
other += "-{}".format(desc)
|
|
|
|
|
2019-09-06 14:42:38 +02:00
|
|
|
self.output["title"] = filenamify(name)
|
2018-05-13 13:06:45 +02:00
|
|
|
self.output["id"] = id
|
|
|
|
self.output["season"] = season
|
|
|
|
self.output["episode"] = episode
|
|
|
|
self.output["episodename"] = other
|
2015-12-27 14:40:27 +01:00
|
|
|
|
|
|
|
def seasoninfo(self, data):
|
2018-10-21 08:36:38 +02:00
|
|
|
season, episode = None, None
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
if "episode" not in data:
|
2019-09-06 14:42:38 +02:00
|
|
|
return season, episode
|
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
if "positionInSeason" not in data["episode"]:
|
2019-09-06 14:42:38 +02:00
|
|
|
return season, episode
|
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
match = re.search(r"Säsong (\d+) — Avsnitt (\d+)", data["episode"]["positionInSeason"])
|
2019-09-06 14:42:38 +02:00
|
|
|
if not match:
|
|
|
|
return season, episode
|
|
|
|
|
2019-09-06 22:06:33 +02:00
|
|
|
season = "{:02d}".format(int(match.group(1)))
|
|
|
|
episode = "{:02d}".format(int(match.group(2)))
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2018-10-21 08:36:38 +02:00
|
|
|
return season, episode
|
2018-07-22 11:07:27 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
def extrametadata(self, episode):
|
2019-09-06 22:49:49 +02:00
|
|
|
self.output["tvshow"] = self.output["season"] is not None and self.output["episode"] is not None
|
2019-09-06 14:42:38 +02:00
|
|
|
if "validFrom" in episode:
|
2019-09-08 00:11:16 +02:00
|
|
|
|
|
|
|
def _fix_broken_timezone_implementation(value):
|
2019-09-12 20:51:31 +02:00
|
|
|
# cx_freeze cant include .zip file for dateutil and < py37 have issues with timezones with : in it
|
2019-09-29 23:45:16 +02:00
|
|
|
if "+" in value and ":" == value[-3:-2]:
|
2019-09-08 00:11:16 +02:00
|
|
|
value = value[:-3] + value[-2:]
|
|
|
|
return value
|
|
|
|
|
2019-09-29 23:45:16 +02:00
|
|
|
validfrom = episode["validFrom"]
|
|
|
|
if "+" in validfrom:
|
|
|
|
date = time.mktime(
|
2019-09-12 20:51:31 +02:00
|
|
|
datetime.datetime.strptime(
|
2020-12-26 13:10:56 +01:00
|
|
|
_fix_broken_timezone_implementation(episode["validFrom"].replace("Z", "")),
|
|
|
|
"%Y-%m-%dT%H:%M:%S%z",
|
|
|
|
).timetuple(),
|
2019-09-12 20:51:31 +02:00
|
|
|
)
|
2019-09-29 23:45:16 +02:00
|
|
|
else:
|
|
|
|
date = time.mktime(
|
|
|
|
datetime.datetime.strptime(
|
2020-12-26 13:10:56 +01:00
|
|
|
_fix_broken_timezone_implementation(episode["validFrom"].replace("Z", "")),
|
|
|
|
"%Y-%m-%dT%H:%M:%S",
|
|
|
|
).timetuple(),
|
2019-09-29 23:45:16 +02:00
|
|
|
)
|
|
|
|
self.output["publishing_datetime"] = int(date)
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
self.output["title_nice"] = episode["parent"]["name"]
|
2018-09-26 16:39:58 +02:00
|
|
|
|
2018-07-22 11:07:27 +02:00
|
|
|
try:
|
2021-02-10 22:57:27 +01:00
|
|
|
t = episode["parent"]["image"]
|
2018-09-26 16:39:58 +02:00
|
|
|
except KeyError:
|
|
|
|
t = ""
|
|
|
|
if isinstance(t, dict):
|
2019-09-06 22:49:49 +02:00
|
|
|
url = "https://www.svtstatic.se/image/original/default/{id}/{changed}?format=auto&quality=100".format(**t)
|
2018-09-26 16:39:58 +02:00
|
|
|
self.output["showthumbnailurl"] = url
|
|
|
|
elif t:
|
2018-07-22 11:07:27 +02:00
|
|
|
# Get the image if size/format is not specified in the URL set it to large
|
2018-09-26 16:39:58 +02:00
|
|
|
url = t.format(format="large")
|
2018-07-22 11:07:27 +02:00
|
|
|
self.output["showthumbnailurl"] = url
|
|
|
|
try:
|
2021-02-07 12:35:18 +01:00
|
|
|
t = episode["image"]
|
2018-07-22 11:46:15 +02:00
|
|
|
except KeyError:
|
2019-09-06 14:42:38 +02:00
|
|
|
t = ""
|
2018-09-26 16:39:58 +02:00
|
|
|
if isinstance(t, dict):
|
2019-09-06 22:49:49 +02:00
|
|
|
url = "https://www.svtstatic.se/image/original/default/{id}/{changed}?format=auto&quality=100".format(**t)
|
2018-09-26 16:39:58 +02:00
|
|
|
self.output["episodethumbnailurl"] = url
|
|
|
|
elif t:
|
2018-07-22 11:07:27 +02:00
|
|
|
# Get the image if size/format is not specified in the URL set it to large
|
2018-09-26 16:39:58 +02:00
|
|
|
url = t.format(format="large")
|
2018-07-22 11:07:27 +02:00
|
|
|
self.output["episodethumbnailurl"] = url
|
2019-09-06 14:42:38 +02:00
|
|
|
|
2021-02-07 12:35:18 +01:00
|
|
|
if "longDescription" in episode["parent"]:
|
|
|
|
self.output["showdescription"] = episode["parent"]["longDescription"]
|
2019-09-06 14:42:38 +02:00
|
|
|
|
|
|
|
if "longDescription" in episode:
|
|
|
|
self.output["episodedescription"] = episode["longDescription"]
|