mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-09-29 15:31:08 -04:00
110 lines
6.1 KiB
Plaintext
110 lines
6.1 KiB
Plaintext
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
__license__ = 'GPL v3'
|
|
__copyright__ = '2010-2012, Darko Miletic <darko.miletic at gmail.com>'
|
|
'''
|
|
www.elpais.com
|
|
'''
|
|
|
|
from calibre.web.feeds.news import BasicNewsRecipe
|
|
|
|
class ElPais_RSS(BasicNewsRecipe):
|
|
title = u'El País'
|
|
__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.'
|
|
publisher = 'EDICIONES EL PAIS, S.L.'
|
|
category = 'news, politics, finances, world, spain'
|
|
oldest_article = 2
|
|
max_articles_per_feed = 200
|
|
no_stylesheets = True
|
|
encoding = 'utf8'
|
|
use_embedded_content = False
|
|
language = 'es'
|
|
remove_empty_feeds = True
|
|
publication_type = 'newspaper'
|
|
masthead_url = 'http://ep01.epimg.net/iconos/v1.x/v1.0/logos/cabecera_portada.png'
|
|
extra_css = """
|
|
h1{font-family: Georgia,"Times New Roman",Times,serif }
|
|
#subtitulo_noticia, .firma, .figcaption{font-size: small}
|
|
body{font-family: Arial,Helvetica,Garuda,sans-serif}
|
|
img{margin-bottom: 0.4em; display:block}
|
|
"""
|
|
|
|
conversion_options = {
|
|
'comment' : description
|
|
, 'tags' : category
|
|
, 'publisher' : publisher
|
|
, 'language' : language
|
|
}
|
|
|
|
keep_only_tags = [
|
|
dict(attrs={'id':['titulo_noticia','subtitulo_noticia']})
|
|
,dict(attrs={'class':['firma','columna_texto','entrevista_p_r']})
|
|
]
|
|
remove_tags = [
|
|
dict(name=['meta','link','base','iframe','embed','object'])
|
|
,dict(attrs={'class':'disposicion_vertical'})
|
|
]
|
|
|
|
feeds = [
|
|
(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'Mexico' , u'http://elpais.com/tag/rss/mexico/a/' )
|
|
,(u'Europa' , u'http://elpais.com/tag/rss/europa/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'Andalucia' , u'http://ep00.epimg.net/rss/ccaa/andalucia.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'Madrid' , u'http://ep00.epimg.net/rss/ccaa/madrid.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'Sociedad' , u'http://ep00.epimg.net/rss/sociedad/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'Cine' , u'http://elpais.com/tag/rss/cine/a/' )
|
|
,(u'Economía' , u'http://elpais.com/tag/rss/economia/a/' )
|
|
,(u'Literatura' , u'http://elpais.com/tag/rss/libros/a/' )
|
|
,(u'Musica' , u'http://elpais.com/tag/rss/musica/a/' )
|
|
,(u'Arte' , u'http://elpais.com/tag/rss/arte/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'Ciencia' , u'http://ep00.epimg.net/rss/tags/c_ciencia.xml' )
|
|
,(u'Salud' , u'http://elpais.com/tag/rss/salud/a/' )
|
|
,(u'Ocio' , u'http://elpais.com/tag/rss/ocio/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'Politica' , u'http://ep00.epimg.net/rss/politica/portada.xml' )
|
|
,(u'Opinion' , u'http://ep01.epimg.net/rss/politica/opinion.xml' )
|
|
]
|
|
|
|
def 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)):
|
|
return url
|
|
self.log('Skipping non-article', url)
|
|
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
|