From 1f6f28cffed146cb2e0d1085671e5bcb64ff912b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Nov 2010 15:14:58 -0700 Subject: [PATCH] Now Toronto by Starson17 --- resources/recipes/now_toronto.recipe | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 resources/recipes/now_toronto.recipe diff --git a/resources/recipes/now_toronto.recipe b/resources/recipes/now_toronto.recipe new file mode 100644 index 0000000000..41741dbccb --- /dev/null +++ b/resources/recipes/now_toronto.recipe @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +#Based on Lars Jacob's Taz Digiabo recipe + +__license__ = 'GPL v3' +__copyright__ = '2010, Starson17' + +import os, urllib2, zipfile +from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ptempfile import PersistentTemporaryFile + +class NowToronto(BasicNewsRecipe): + title = u'Now Toronto' + description = u'Now Toronto' + __author__ = 'Starson17' + conversion_options = { + 'no_default_epub_cover' : True + } + + def build_index(self): + epub_feed = "http://feeds.feedburner.com/NowEpubEditions" + soup = self.index_to_soup(epub_feed) + url = soup.find(name = 'feedburner:origlink').string + f = urllib2.urlopen(url) + tmp = PersistentTemporaryFile(suffix='.epub') + self.report_progress(0,_('downloading epub')) + tmp.write(f.read()) + tmp.close() + zfile = zipfile.ZipFile(tmp.name, '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