mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Taz DigiABO by Lars Jacob
This commit is contained in:
parent
d4e611508a
commit
81056a21cb
62
resources/recipes/taz.recipe
Normal file
62
resources/recipes/taz.recipe
Normal file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Lars Jacob jacob.lars at gmail.com'
|
||||
__docformat__ = 'restructuredtext de'
|
||||
|
||||
'''
|
||||
www.taz.de/digiabo
|
||||
'''
|
||||
import os, urllib2, zipfile, tempfile
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class TazDigiabo(BasicNewsRecipe):
|
||||
|
||||
title = u'Taz Digiabo'
|
||||
description = u'Das EPUB DigiAbo der Taz'
|
||||
language = 'de'
|
||||
lang = 'de-DE'
|
||||
|
||||
__author__ = 'Lars Jacob'
|
||||
needs_subscription = True
|
||||
|
||||
conversion_options = {
|
||||
'no_default_epub_cover' : True
|
||||
}
|
||||
|
||||
def build_index(self):
|
||||
if self.username is not None and self.password is not None:
|
||||
domain = "http://www.taz.de"
|
||||
|
||||
url = domain + "/epub/"
|
||||
|
||||
auth_handler = urllib2.HTTPBasicAuthHandler()
|
||||
auth_handler.add_password(realm='TAZ-ABO',
|
||||
uri=url,
|
||||
user=self.username,
|
||||
passwd=self.password)
|
||||
opener = urllib2.build_opener(auth_handler)
|
||||
urllib2.install_opener(opener)
|
||||
|
||||
try:
|
||||
f = urllib2.urlopen(url)
|
||||
except urllib2.HTTPError:
|
||||
self.report_progress(0,_('Can\'t login to download issue'))
|
||||
return
|
||||
|
||||
tmp = tempfile.TemporaryFile()
|
||||
self.report_progress(0,_('downloading epub'))
|
||||
tmp.write(f.read())
|
||||
|
||||
zfile = zipfile.ZipFile(tmp, 'r')
|
||||
self.report_progress(0,_('extracting epub'))
|
||||
|
||||
zfile.extractall(self.output_dir)
|
||||
|
||||
tmp.close()
|
||||
index = os.path.join(self.output_dir, 'content.opf')
|
||||
|
||||
self.report_progress(1,_('epub downloaded and extracted'))
|
||||
|
||||
return index
|
Loading…
x
Reference in New Issue
Block a user