mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 21:54:17 +01:00
Working thumbnail download. Used by svtplay and barnkanalen, downloads both episode and show thumbnails.
This commit is contained in:
parent
dbdf7dc851
commit
bf0e38a6f9
@ -16,11 +16,12 @@ from svtplay_dl.fetcher.hls import hlsparse
|
|||||||
from svtplay_dl.fetcher.dash import dashparse
|
from svtplay_dl.fetcher.dash import dashparse
|
||||||
from svtplay_dl.subtitle import subtitle
|
from svtplay_dl.subtitle import subtitle
|
||||||
from svtplay_dl.error import ServiceError
|
from svtplay_dl.error import ServiceError
|
||||||
|
from svtplay_dl.utils.http import download_thumbnails
|
||||||
|
|
||||||
URL_VIDEO_API = "http://api.svt.se/videoplayer-api/video/"
|
URL_VIDEO_API = "http://api.svt.se/videoplayer-api/video/"
|
||||||
|
|
||||||
|
|
||||||
class Svtplay(Service, OpenGraphThumbMixin):
|
class Svtplay(Service):
|
||||||
supported_domains = ['svtplay.se', 'svt.se', 'beta.svtplay.se', 'svtflow.se']
|
supported_domains = ['svtplay.se', 'svt.se', 'beta.svtplay.se', 'svtflow.se']
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
@ -298,3 +299,12 @@ class Svtplay(Service, OpenGraphThumbMixin):
|
|||||||
self.output["episodedescription"] = data["video"]["description"]
|
self.output["episodedescription"] = data["video"]["description"]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_thumbnail(self, options):
|
||||||
|
urls = []
|
||||||
|
if self.output["showthumbnailurl"] is not None:
|
||||||
|
urls.append((True, self.output["showthumbnailurl"]))
|
||||||
|
if self.output["episodethumbnailurl"] is not None:
|
||||||
|
urls.append((False, self.output["episodethumbnailurl"]))
|
||||||
|
if urls:
|
||||||
|
download_thumbnails(self.output, options, urls)
|
@ -5,7 +5,8 @@ from urllib.parse import urljoin
|
|||||||
from requests import Session
|
from requests import Session
|
||||||
from requests.adapters import HTTPAdapter
|
from requests.adapters import HTTPAdapter
|
||||||
from requests.packages.urllib3.util.retry import Retry
|
from requests.packages.urllib3.util.retry import Retry
|
||||||
|
from svtplay_dl.utils.output import formatname
|
||||||
|
from svtplay_dl.utils.parser import Options
|
||||||
|
|
||||||
# Used for UA spoofing in get_http_data()
|
# Used for UA spoofing in get_http_data()
|
||||||
FIREFOX_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.3'
|
FIREFOX_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.3'
|
||||||
@ -60,6 +61,28 @@ def download_thumbnail(options, url):
|
|||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
|
|
||||||
|
def download_thumbnails(output, config, urls):
|
||||||
|
for show, url in urls:
|
||||||
|
data = Session().get(url).content
|
||||||
|
|
||||||
|
if show:
|
||||||
|
# Config for downloading show thumbnail
|
||||||
|
cconfig = Options()
|
||||||
|
cconfig.set("output", config.get("output"))
|
||||||
|
cconfig.set("path", config.get("path"))
|
||||||
|
cconfig.set("subfolder", config.get("subfolder"))
|
||||||
|
cconfig.set("filename", "{title}.tvshow.{ext}")
|
||||||
|
else:
|
||||||
|
cconfig = config
|
||||||
|
|
||||||
|
filename = formatname(output.copy(), cconfig, extension="tbn")
|
||||||
|
logging.info("Thumbnail: %s", filename)
|
||||||
|
|
||||||
|
fd = open(filename, "wb")
|
||||||
|
fd.write(data)
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
|
||||||
def get_full_url(url, srcurl):
|
def get_full_url(url, srcurl):
|
||||||
if url[:4] == 'http':
|
if url[:4] == 'http':
|
||||||
return url
|
return url
|
||||||
|
Loading…
Reference in New Issue
Block a user