1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00

Get extra metadata, like thumbnails and descriptions. Currently implemented for svtplay and barnkanalen.

This commit is contained in:
Harald Gustafsson 2018-07-22 11:07:27 +02:00 committed by Johan Andersson
parent 71b40f975a
commit dbdf7dc851
3 changed files with 37 additions and 1 deletions

View File

@ -22,7 +22,10 @@ class Service(object):
self.cookies = {}
self.auto_name = None
self.output = {"title": None, "season": None, "episode": None, "episodename": None,
"id": None, "service": self.__class__.__name__.lower()}
"id": None, "service": self.__class__.__name__.lower(),
"tvshow": None, "title_nice": None, "showdescription": None,
"episodedescription": None, "showthumbnailurl": None,
"episodethumbnailurl": None}
if not http:
self.http = HTTP(config)
else:

View File

@ -53,6 +53,7 @@ class Barnkanalen(Svtplay):
self.config.set("live", janson["video"]["live"])
self.outputfilename(janson["video"])
self.extrametadata(janson)
if "programVersionId" in janson["video"]:
vid = janson["video"]["programVersionId"]

View File

@ -70,6 +70,7 @@ class Svtplay(Service, OpenGraphThumbMixin):
janson = json.loads(match.group(1))["videoPage"]
self.outputfilename(janson["video"])
self.extrametadata(janson)
if "programVersionId" in janson["video"]:
vid = janson["video"]["programVersionId"]
@ -266,3 +267,34 @@ class Svtplay(Service, OpenGraphThumbMixin):
return season, episode
else:
return None, None
def extrametadata(self, data):
self.output["tvshow"] = (self.output["season"] is not None and
self.output["episode"] is not None)
try:
title = data["video"]["programTitle"]
self.output["title_nice"] = title
except:
title = data["video"]["titleSlug"]
self.output["title_nice"] = title
try:
# Get the image if size/format is not specified in the URL set it to large
url = data['state']["titleModel"]["thumbnail"].format(format="large")
self.output["showthumbnailurl"] = url
except:
pass
try:
url = data["video"]["thumbnailXL"].format(format="large")
self.output["episodethumbnailurl"] = url
except:
# Get the image if size/format is not specified in the URL set it to large
url = data["video"]["thumbnail"].format(format="large")
self.output["episodethumbnailurl"] = url
try:
self.output["showdescription"] = data['state']["titleModel"]["description"]
except:
pass
try:
self.output["episodedescription"] = data["video"]["description"]
except:
pass