mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
...
This commit is contained in:
parent
74a63ac46f
commit
e8f6b4e659
@ -13,50 +13,51 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
|||||||
|
|
||||||
class TazDigiabo(BasicNewsRecipe):
|
class TazDigiabo(BasicNewsRecipe):
|
||||||
|
|
||||||
title = u'Taz Digiabo'
|
title = u'Taz Digiabo'
|
||||||
description = u'Das EPUB DigiAbo der Taz'
|
description = u'Das EPUB DigiAbo der Taz'
|
||||||
language = 'de'
|
language = 'de'
|
||||||
lang = 'de-DE'
|
lang = 'de-DE'
|
||||||
|
|
||||||
__author__ = 'Lars Jacob'
|
__author__ = 'Lars Jacob'
|
||||||
needs_subscription = True
|
needs_subscription = True
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'no_default_epub_cover' : True
|
'no_default_epub_cover' : True
|
||||||
}
|
}
|
||||||
|
|
||||||
def build_index(self):
|
def build_index(self):
|
||||||
if self.username is not None and self.password is not None:
|
if self.username is not None and self.password is not None:
|
||||||
domain = "http://www.taz.de"
|
domain = "http://www.taz.de"
|
||||||
|
|
||||||
url = domain + "/epub/"
|
url = domain + "/epub/"
|
||||||
|
|
||||||
auth_handler = urllib2.HTTPBasicAuthHandler()
|
auth_handler = urllib2.HTTPBasicAuthHandler()
|
||||||
auth_handler.add_password(realm='TAZ-ABO',
|
auth_handler.add_password(realm='TAZ-ABO',
|
||||||
uri=url,
|
uri=url,
|
||||||
user=self.username,
|
user=self.username,
|
||||||
passwd=self.password)
|
passwd=self.password)
|
||||||
opener = urllib2.build_opener(auth_handler)
|
opener = urllib2.build_opener(auth_handler)
|
||||||
urllib2.install_opener(opener)
|
urllib2.install_opener(opener)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = urllib2.urlopen(url)
|
f = urllib2.urlopen(url)
|
||||||
except urllib2.HTTPError:
|
except urllib2.HTTPError:
|
||||||
self.report_progress(0,_('Can\'t login to download issue'))
|
self.report_progress(0,_('Can\'t login to download issue'))
|
||||||
return
|
raise ValueError('Failed to login, check your username and'
|
||||||
|
' password')
|
||||||
|
|
||||||
tmp = tempfile.TemporaryFile()
|
tmp = tempfile.TemporaryFile()
|
||||||
self.report_progress(0,_('downloading epub'))
|
self.report_progress(0,_('downloading epub'))
|
||||||
tmp.write(f.read())
|
tmp.write(f.read())
|
||||||
|
|
||||||
zfile = zipfile.ZipFile(tmp, 'r')
|
zfile = zipfile.ZipFile(tmp, 'r')
|
||||||
self.report_progress(0,_('extracting epub'))
|
self.report_progress(0,_('extracting epub'))
|
||||||
|
|
||||||
zfile.extractall(self.output_dir)
|
zfile.extractall(self.output_dir)
|
||||||
|
|
||||||
tmp.close()
|
tmp.close()
|
||||||
index = os.path.join(self.output_dir, 'content.opf')
|
index = os.path.join(self.output_dir, 'content.opf')
|
||||||
|
|
||||||
self.report_progress(1,_('epub downloaded and extracted'))
|
self.report_progress(1,_('epub downloaded and extracted'))
|
||||||
|
|
||||||
return index
|
return index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user