Update El Pais Impreso

Fixes #1299650 [Updated recipe for El Pais](https://bugs.launchpad.net/calibre/+bug/1299650)
This commit is contained in:
Kovid Goyal 2014-03-30 08:10:53 +05:30
parent 2a333aa46a
commit b3e6939edf

View File

@ -1,16 +1,17 @@
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010-2012, Darko Miletic <darko.miletic at gmail.com>' __copyright__ = '2010-2014, Darko Miletic <darko.miletic at gmail.com>'
''' '''
www.elpais.com elpais.com
''' '''
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class ElPais_RSS(BasicNewsRecipe): class ElPais_RSS(BasicNewsRecipe):
title = u'El País' title = u'El País'
__author__ = 'Darko Miletic' __author__ = 'Darko Miletic'
description = u'Noticias de última hora sobre la actualidad en España y el mundo: política, economía, deportes, cultura, sociedad, tecnología, gente, opinión, viajes, moda, televisión, los blogs y las firmas de EL PAÍS. Además especiales, vídeos, fotos, audios, gráficos, entrevistas, promociones y todos los servicios de EL PAÍS.' description = u'Noticias de última hora sobre la actualidad en España y el mundo: política, economía, deportes, cultura, sociedad, tecnología, gente, opinión, viajes, moda, televisión, los blogs y las firmas de EL PAÍS. Además especiales, vídeos, fotos, audios, gráficos, entrevistas, promociones y todos los servicios de EL PAÍS.' # noqa
publisher = 'EDICIONES EL PAIS, S.L.' publisher = 'EDICIONES EL PAIS, S.L.'
category = 'news, politics, finances, world, spain' category = 'news, politics, finances, world, spain'
oldest_article = 2 oldest_article = 2
@ -22,6 +23,7 @@ class ElPais_RSS(BasicNewsRecipe):
remove_empty_feeds = True remove_empty_feeds = True
publication_type = 'newspaper' publication_type = 'newspaper'
masthead_url = 'http://ep01.epimg.net/iconos/v1.x/v1.0/logos/cabecera_portada.png' masthead_url = 'http://ep01.epimg.net/iconos/v1.x/v1.0/logos/cabecera_portada.png'
cover_url = strftime('http://srv00.epimg.net/pdf/elpais/1aPagina/%Y/%m/ep-%Y%m%d.pdf')
extra_css = """ extra_css = """
h1{font-family: Georgia,"Times New Roman",Times,serif } h1{font-family: Georgia,"Times New Roman",Times,serif }
#subtitulo_noticia, .firma, .figcaption{font-size: small} #subtitulo_noticia, .firma, .figcaption{font-size: small}
@ -47,68 +49,42 @@ class ElPais_RSS(BasicNewsRecipe):
feeds = [ feeds = [
(u'Lo ultimo' , u'http://ep00.epimg.net/rss/tags/ultimas_noticias.xml') (u'Lo ultimo' , u'http://ep00.epimg.net/rss/tags/ultimas_noticias.xml')
,(u'America Latina' , u'http://elpais.com/tag/rss/latinoamerica/a/' ) ,(u'America Latina' , u'http://elpais.com/tag/rss/latinoamerica/a/')
,(u'Mexico' , u'http://elpais.com/tag/rss/mexico/a/' ) ,(u'Mexico' , u'http://elpais.com/tag/rss/mexico/a/')
,(u'Europa' , u'http://elpais.com/tag/rss/europa/a/' ) ,(u'Europa' , u'http://elpais.com/tag/rss/europa/a/')
,(u'Estados Unidos' , u'http://elpais.com/tag/rss/estados_unidos/a/' ) ,(u'Estados Unidos' , u'http://elpais.com/tag/rss/estados_unidos/a/')
,(u'Oriente proximo' , u'http://elpais.com/tag/rss/oriente_proximo/a/' ) ,(u'Oriente proximo' , u'http://elpais.com/tag/rss/oriente_proximo/a/')
,(u'Andalucia' , u'http://ep00.epimg.net/rss/ccaa/andalucia.xml' ) ,(u'Andalucia' , u'http://ep00.epimg.net/rss/ccaa/andalucia.xml')
,(u'Catalunia' , u'http://ep00.epimg.net/rss/ccaa/catalunya.xml' ) ,(u'Catalunia' , u'http://ep00.epimg.net/rss/ccaa/catalunya.xml')
,(u'Comunidad Valenciana' , u'http://ep00.epimg.net/rss/ccaa/valencia.xml' ) ,(u'Comunidad Valenciana' , u'http://ep00.epimg.net/rss/ccaa/valencia.xml')
,(u'Madrid' , u'http://ep00.epimg.net/rss/ccaa/madrid.xml' ) ,(u'Madrid' , u'http://ep00.epimg.net/rss/ccaa/madrid.xml')
,(u'Pais Vasco' , u'http://ep00.epimg.net/rss/ccaa/paisvasco.xml' ) ,(u'Pais Vasco' , u'http://ep00.epimg.net/rss/ccaa/paisvasco.xml')
,(u'Galicia' , u'http://ep00.epimg.net/rss/ccaa/galicia.xml' ) ,(u'Galicia' , u'http://ep00.epimg.net/rss/ccaa/galicia.xml')
,(u'Sociedad' , u'http://ep00.epimg.net/rss/sociedad/portada.xml' ) ,(u'Sociedad' , u'http://ep00.epimg.net/rss/sociedad/portada.xml')
,(u'Deportes' , u'http://ep00.epimg.net/rss/deportes/portada.xml' ) ,(u'Deportes' , u'http://ep00.epimg.net/rss/deportes/portada.xml')
,(u'Cultura' , u'http://ep00.epimg.net/rss/cultura/portada.xml' ) ,(u'Cultura' , u'http://ep00.epimg.net/rss/cultura/portada.xml')
,(u'Cine' , u'http://elpais.com/tag/rss/cine/a/' ) ,(u'Cine' , u'http://elpais.com/tag/rss/cine/a/')
,(u'Economía' , u'http://elpais.com/tag/rss/economia/a/' ) ,(u'Economía' , u'http://elpais.com/tag/rss/economia/a/')
,(u'Literatura' , u'http://elpais.com/tag/rss/libros/a/' ) ,(u'Literatura' , u'http://elpais.com/tag/rss/libros/a/')
,(u'Musica' , u'http://elpais.com/tag/rss/musica/a/' ) ,(u'Musica' , u'http://elpais.com/tag/rss/musica/a/')
,(u'Arte' , u'http://elpais.com/tag/rss/arte/a/' ) ,(u'Arte' , u'http://elpais.com/tag/rss/arte/a/')
,(u'Medio Ambiente' , u'http://elpais.com/tag/rss/medio_ambiente/a/' ) ,(u'Medio Ambiente' , u'http://elpais.com/tag/rss/medio_ambiente/a/')
,(u'Tecnologia' , u'http://ep01.epimg.net/rss/tecnologia/portada.xml' ) ,(u'Tecnologia' , u'http://ep01.epimg.net/rss/tecnologia/portada.xml')
,(u'Ciencia' , u'http://ep00.epimg.net/rss/tags/c_ciencia.xml' ) ,(u'Ciencia' , u'http://ep00.epimg.net/rss/tags/c_ciencia.xml')
,(u'Salud' , u'http://elpais.com/tag/rss/salud/a/' ) ,(u'Salud' , u'http://elpais.com/tag/rss/salud/a/')
,(u'Ocio' , u'http://elpais.com/tag/rss/ocio/a/' ) ,(u'Ocio' , u'http://elpais.com/tag/rss/ocio/a/')
,(u'Justicia y Leyes' , u'http://elpais.com/tag/rss/justicia/a/' ) ,(u'Justicia y Leyes' , u'http://elpais.com/tag/rss/justicia/a/')
,(u'Guerras y conflictos' , u'http://elpais.com/tag/rss/conflictos/a/' ) ,(u'Guerras y conflictos' , u'http://elpais.com/tag/rss/conflictos/a/')
,(u'Politica' , u'http://ep00.epimg.net/rss/politica/portada.xml' ) ,(u'Politica' , u'http://ep00.epimg.net/rss/politica/portada.xml')
,(u'Opinion' , u'http://ep01.epimg.net/rss/elpais/opinion.xml' ) ,(u'Opinion' , u'http://ep01.epimg.net/rss/elpais/opinion.xml')
] ]
def get_article_url(self, article): def get_article_url(self, article):
url = BasicNewsRecipe.get_article_url(self, article) url = BasicNewsRecipe.get_article_url(self, article)
if url and (not('/album/' in url) and not('/futbol/partido/' in url)): if url and (not('/album/' in url) and not('/futbol/partido/' in url)):
urlverified = self.browser.open_novisit(url).geturl() return url
return urlverified
self.log('Skipping non-article', url) self.log('Skipping non-article', url)
return None return None
def get_cover_url(self):
soup = self.index_to_soup('http://elpais.com/')
for image in soup.findAll('img'):
if image['src'].endswith('elpaisTodayMiddle.jpg'):
sstr = image['src']
return sstr.replace('elpaisTodayMiddle.jpg', 'elpaisToday.jpg')
return None
def preprocess_html(self, soup):
for item in soup.findAll(style=True):
del item['style']
for item in soup.findAll('a'):
if item.string is not None:
tstr = item.string
item.replaceWith(tstr)
else:
item.name='span'
for atrs in ['href','target','alt','title']:
if item.has_key(atrs):
del item[atrs]
for item in soup.findAll('img',alt=False):
item['alt'] = 'image'
return soup
def preprocess_raw_html(self, raw, url): def preprocess_raw_html(self, raw, url):
return '<html><head><title>Untitled</title>'+raw[raw.find('</head>'):] return '<html><head><title>Untitled</title>'+raw[raw.find('</head>'):]