1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-28 06:04:17 +01:00

subtitle: support for cookies

This commit is contained in:
Johan Andersson 2014-11-25 18:43:40 +01:00
parent fa6a4c61d2
commit e94975b256
2 changed files with 10 additions and 12 deletions

View File

@ -60,6 +60,7 @@ class Options(object):
self.verbose = False
self.output_auto = False
self.service = None
self.cookies = None
def get_media(url, options):

View File

@ -12,19 +12,16 @@ class subtitle(object):
self.options = options
self.subtype = subtype
def get_subdata(self):
if self.subtitle is None:
try:
self.subtitle = get_http_data(self.url)
except HTTPError:
return None
return self.subtitle
def download(self):
subdata = self.get_subdata()
if subdata is None:
log.error("Can't download subtitle.")
return
try:
subdata = get_http_data(self.url, cookiejar=self.options.cookies)
except HTTPError as e:
if e.code == 403:
log.error("Permission denied")
return
else:
log.error("Can't download subtitle")
return
data = None
if self.subtype == "tt":