From ba3ca34c045630781184d725194aef0307220a92 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 4 Apr 2009 06:58:22 -0700 Subject: [PATCH] New recipe for the Arizona Star by Darko Miletic --- src/calibre/ebooks/__init__.py | 1 + src/calibre/gui2/__init__.py | 2 - src/calibre/gui2/images/news/azstarnet.png | Bin 0 -> 360 bytes src/calibre/web/feeds/recipes/__init__.py | 2 +- .../web/feeds/recipes/recipe_azstarnet.py | 63 ++++++++++++++++++ .../web/feeds/recipes/recipe_wash_post.py | 12 ++-- 6 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 src/calibre/gui2/images/news/azstarnet.png create mode 100644 src/calibre/web/feeds/recipes/recipe_azstarnet.py diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index e208b5a688..26d2394818 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -1,3 +1,4 @@ +from __future__ import with_statement __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index ffea1ddc20..225f7a9e33 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -466,5 +466,3 @@ class Application(QApplication): self.translator.loadFromData(data) self.installTranslator(self.translator) - - diff --git a/src/calibre/gui2/images/news/azstarnet.png b/src/calibre/gui2/images/news/azstarnet.png new file mode 100644 index 0000000000000000000000000000000000000000..33ad360ca0690e1089caa876cbea823111649764 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*VRoQa+;jv*GOw+2OXu_*GaF5YAtwI?#~+RqDo zp~`xja~3>U?I~sQo1J0DY+lv_{ko=I zEOiY`fGEV!*viz@%EVmTz`)AD;CX2IMwo`&{FKbJN=yw#R)&^9r4S8$Rn-+h4Gf;H KelF{r5}E)Vp?bOi literal 0 HcmV?d00001 diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 33763f83ce..0de3f66bc8 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -37,7 +37,7 @@ recipe_modules = ['recipe_' + r for r in ( 'new_york_review_of_books_no_sub', 'politico', 'adventuregamers', 'mondedurable', 'instapaper', 'dnevnik_cro', 'vecernji_list', 'nacional_cro', '24sata', 'dnevni_avaz', 'glas_srpske', '24sata_rs', - 'krstarica', 'krstarica_en', 'tanjug', 'laprensa_ni', + 'krstarica', 'krstarica_en', 'tanjug', 'laprensa_ni', 'azstarnet', )] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/recipe_azstarnet.py b/src/calibre/web/feeds/recipes/recipe_azstarnet.py new file mode 100644 index 0000000000..55cfcf78f1 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_azstarnet.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2009, Darko Miletic ' +''' +www.azstarnet.com +''' + +from calibre.web.feeds.news import BasicNewsRecipe + +class Azstarnet(BasicNewsRecipe): + title = 'Arizona Daily Star' + __author__ = 'Darko Miletic' + description = 'news from Arizona' + publisher = 'azstarnet.com' + category = 'news, politics, Arizona, USA' + delay = 1 + oldest_article = 1 + max_articles_per_feed = 100 + no_stylesheets = True + use_embedded_content = False + encoding = 'utf-8' + needs_subscription = True + remove_javascript = True + + html2lrf_options = [ + '--comment', description + , '--category', category + , '--publisher', publisher + ] + + html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"' + + def get_browser(self): + br = BasicNewsRecipe.get_browser() + if self.username is not None and self.password is not None: + br.open('http://azstarnet.com/registration/retro.php') + br.select_form(nr=1) + br['email'] = self.username + br['pass' ] = self.password + br.submit() + return br + + + keep_only_tags = [dict(name='div', attrs={'id':'storycontent'})] + + remove_tags = [ + dict(name=['object','link','iframe','base','img']) + ,dict(name='div',attrs={'class':'bannerinstory'}) + ] + + + feeds = [(u'Tucson Region', u'http://rss.azstarnet.com/index.php?site=metro')] + + def preprocess_html(self, soup): + soup.html['dir' ] = 'ltr' + soup.html['lang'] = 'en-US' + mtag = '\n\n\n' + soup.head.insert(0,mtag) + for item in soup.findAll(style=True): + del item['style'] + return soup + \ No newline at end of file diff --git a/src/calibre/web/feeds/recipes/recipe_wash_post.py b/src/calibre/web/feeds/recipes/recipe_wash_post.py index dc85126065..144e323f20 100644 --- a/src/calibre/web/feeds/recipes/recipe_wash_post.py +++ b/src/calibre/web/feeds/recipes/recipe_wash_post.py @@ -11,13 +11,13 @@ class WashingtonPost(BasicNewsRecipe): max_articles_per_feed = 20 language = _('English') - - remove_javascript = True - + remove_javascript = True + + feeds = [ ('Today\'s Highlights', 'http://www.washingtonpost.com/wp-dyn/rss/linkset/2005/03/24/LI2005032400102.xml'), ('Politics', 'http://www.washingtonpost.com/wp-dyn/rss/politics/index.xml'), - ('Nation', 'http://www.www.washingtonpost.com/wp-dyn/rss/nation/index.xml'), + ('Nation', 'http://www.washingtonpost.com/wp-dyn/rss/nation/index.xml'), ('World', 'http://www.washingtonpost.com/wp-dyn/rss/world/index.xml'), ('Business', 'http://www.washingtonpost.com/wp-dyn/rss/business/index.xml'), ('Technology', 'http://www.washingtonpost.com/wp-dyn/rss/technology/index.xml'), @@ -25,7 +25,7 @@ class WashingtonPost(BasicNewsRecipe): ('Education', 'http://www.washingtonpost.com/wp-dyn/rss/education/index.xml'), ('Editorials', 'http://www.washingtonpost.com/wp-dyn/rss/linkset/2005/05/30/LI2005053000331.xml'), ] - + remove_tags = [{'id':['pfmnav', 'ArticleCommentsWrapper']}] @@ -34,7 +34,7 @@ class WashingtonPost(BasicNewsRecipe): def print_version(self, url): return url.rpartition('.')[0] + '_pf.html' - + def postprocess_html(self, soup, first): for div in soup.findAll(name='div', style=re.compile('margin')): div['style'] = ''