Hi there,
This is an old post, but hope you can help me out with the recipe? Not working currently with Calibre!
Thanks, Niels
Quote:
Originally Posted by realbase
I retried to trie to do something with your feedback.
(I followed the same route as this guy does: http://l_uka.pentax.org.pl/calibre/biweekly.recipe )
Now the code looks like this, and it really works:
Code:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#Based on veezh's original recipe and Kovid Goyal's New York Times recipe and Snaab's NRC-epub recipe
__license__ = 'GPL v3'
__copyright__ = '2013, RealBase'
'''
www.groene.nl
'''
import os, zipfile
import time
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ptempfile import PersistentTemporaryFile
from calibre.ebooks.conversion.cli import main
class GroeneAmsterdammer(BasicNewsRecipe):
title = u'De Groene Amsterdammer'
description = u'De ePub-versie van de Groene Amsterdammer'
language = 'nl'
lang = 'nl-NL'
needs_subscription = True
__author__ = 'Realbase'
conversion_options = {
'no_default_epub_cover' : True
}
def get_browser(self):
br = BasicNewsRecipe.get_browser(self)
if self.username is not None and self.password is not None:
br.open('https://www.groene.nl/sessie/new')
print [form for form in br.forms()][1]
br.select_form(nr=1)
br['user_session[login]'] = self.username
br['user_session[password]'] = self.password
br.submit()
return br
def build_index(self):
domain = "http://www.groene.nl"
url = domain + "/deze-week.epub"
#print url
try:
br = self.get_browser()
f = br.open(url)
except:
self.report_progress(0,_('Kan niet inloggen om editie te downloaden'))
raise ValueError('Groene van deze week nog niet beschikbaar')
self.report_progress(0,_('downloading epub'))
book_file = PersistentTemporaryFile(suffix='.epub')
book_file.write(f.read())
f.close()
br.close()
book_file.close()
# convert
self.report_progress(0.2,_('Converting to OEB'))
oebdir = self.output_dir + '/INPUT/'
main(['ebook-convert', book_file.name, oebdir])
#feed calibre
index = os.path.join(oebdir, 'content.opf')
return index
|