From f688c8c3b3cb8d6dbcc35895ee5a5ae3c70f6a9e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Jan 2009 16:11:12 -0800 Subject: [PATCH] Recipe for La Prensa by Darko Miletic --- src/calibre/web/feeds/recipes/__init__.py | 3 +- .../web/feeds/recipes/recipe_laprensa.py | 50 +++++++++++++++++++ src/calibre/web/fetch/simple.py | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/calibre/web/feeds/recipes/recipe_laprensa.py diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 96dec2e032..2b5652260d 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -22,7 +22,8 @@ recipe_modules = ['recipe_' + r for r in ( 'time_magazine', 'endgadget', 'fudzilla', 'nspm_int', 'nspm', 'pescanik', 'spiegel_int', 'themarketticker', 'tomshardware', 'xkcd', 'ftd', 'zdnet', 'joelonsoftware', 'telepolis', 'common_dreams', 'nin', 'tomshardware_de', - 'pagina12', 'infobae', 'ambito', 'elargentino', 'sueddeutsche', 'the_age', + 'pagina12', 'infobae', 'ambito', 'elargentino', 'sueddeutsche', 'the_age', + 'laprensa', )] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/recipe_laprensa.py b/src/calibre/web/feeds/recipes/recipe_laprensa.py new file mode 100644 index 0000000000..55bb8778a3 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_laprensa.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2008, Darko Miletic ' +''' +laprensa.com.ar +''' +import urllib + +from calibre.web.feeds.news import BasicNewsRecipe + +class LaPrensa(BasicNewsRecipe): + title = 'La Prensa' + __author__ = 'Darko Miletic' + description = 'Informacion Libre las 24 horas' + oldest_article = 7 + max_articles_per_feed = 100 + no_stylesheets = True + use_embedded_content = False + encoding = 'cp1252' + cover_url = 'http://www.laprensa.com.ar/imgs/logo.gif' + + html2lrf_options = [ + '--comment' , description + , '--category' , 'news, Argentina' + , '--publisher' , title + ] + + feeds = [ + (u'Politica' , u'http://www.laprensa.com.ar/Rss.aspx?Rss=4' ) + ,(u'Economia' , u'http://www.laprensa.com.ar/Rss.aspx?Rss=5' ) + ,(u'Opinion' , u'http://www.laprensa.com.ar/Rss.aspx?Rss=6' ) + ,(u'El Mundo' , u'http://www.laprensa.com.ar/Rss.aspx?Rss=7' ) + ,(u'Actualidad' , u'http://www.laprensa.com.ar/Rss.aspx?Rss=8' ) + ,(u'Deportes' , u'http://www.laprensa.com.ar/Rss.aspx?Rss=9' ) + ,(u'Espectaculos', u'http://www.laprensa.com.ar/Rss.aspx?Rss=10') + ] + + def print_version(self, url): + return url.replace('.note.aspx','.NotePrint.note.aspx') + + def get_article_url(self, article): + raw = article.get('link', None).encode('utf8') + final = urllib.quote(raw,':/') + return final + + def preprocess_html(self, soup): + del soup.body['onload'] + return soup + diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index 2e5c8bae70..8e84c5033f 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -398,7 +398,7 @@ class RecursiveFetcher(object, LoggingInterface): _fname = basename(iurl) if not isinstance(_fname, unicode): _fname.decode('latin1', 'replace') - _fname.encode('ascii', 'replace').replace('%', '').replace(os.sep, '') + _fname = _fname.encode('ascii', 'replace').replace('%', '').replace(os.sep, '') res = os.path.join(linkdiskpath, _fname) self.downloaded_paths.append(res) self.filemap[nurl] = res