Hi, people
I made a recipe for
Periodismo Humano, a Spanish online newspaper focused in human rights
Here there is the source code
Code:
import re
from calibre.web.feeds.news import BasicNewsRecipe
class PeriodismoHumanoRecipe(BasicNewsRecipe):
title = u'Periodismo Humano'
__author__ = 'Herrero, L.'
description = 'Periodismo Humano: información que sí importa'
oldest_article = 7
max_articles_per_feed = 100
no_stylesheets = True
encoding = 'utf-8'
publisher = 'Periodismo Humano'
category = 'news, Spain, world'
language = 'es_ES'
publication_type = 'newsportal'
remove_empty_feeds = True
remove_javascript = True
use_embedded_content = False # Luego ya borramos lo que sea
remove_attributes = ['height','width']
extra_css = """
.wp-caption-text{font-family: sans-serif; font-style:italic; font-size:80%; text-align: justify; }
"""
# Vamos a mantener su estilo por ahora
#extra_css = """
# p{text-align: justify; font-size: 100%}
# body{ text-align: justify; font-size:100% }
# h5{font-family: sans-serif; font-size:100%; font-weight:bold; text-align: left; }
# h4{font-family: sans-serif; font-size:110%; font-weight:bold; text-align: left; }
# h3{font-family: sans-serif; font-size:120%; font-weight:bold; text-align: left; }
# h2{font-family: sans-serif; font-size:150%; font-weight:bold; text-align: left; }
# h1{font-family: sans-serif; font-size:150%; font-weight:bold; text-align: left; }
# img {float:left; padding:5px 20px 10px 5px;}
# .author-date-head{font-family: sans-serif; font-size:120%; text-align: left; }
# .subtitle{font-family: sans-serif; font-size:120%; font-weight:bold; text-align: justify; }
# .wp-caption-text{font-family: sans-serif; font-style:italic; font-size:80%; text-align: justify; } #Comentarios de las fotos más pequeños y en cursivas
# """
conversion_options = {
'comments' : description,
'tags' : category,
'language' : language,
'publisher' : publisher
}
def get_cover_url(self):
return 'http://periodismohumano.com/files/2010/01/logoconslogan-300x211.jpg'
# Nos quedamos sólo con el div content y sus hijos
keep_only_tags = [
dict(name='div', attrs={'id':'content'})
]
# De los hijos nos sobran algunas cosas
remove_tags = [
# La categoría la removeremos con expresiones regulares
dict(name='ul', attrs={'id':'share-services-head'}), # Share de arriba
dict(name='div', attrs={'id':'share'}), # Share de abajo
dict(name='div', attrs={'class':'clearfix share'}), # Otro hare de abajo
dict(name='div', attrs={'id':'comments-title'}), # Comentarios
dict(name='div', attrs={'class':'navigation_comment clearfix'}),
dict(name='ol', attrs={'class':'commentlist'}),
dict(name='div', attrs={'id':'respond'}),
dict(name='div', attrs={'id':'sidebar'}),
#comentarios
dict(name='div', attrs={'class':'comments'}),
# Títulos de las secciones
dict(name='h1', attrs={'id':'header-logo'})
]
# Feeds extraidos de la barra de secciones, http://periodismohumano.com/el-equipo y http://periodismohumano.com/seccion/enfoques
feeds = [
#Secciones
(u'Sociedad', u'http://periodismohumano.com/seccion/sociedad/feed/atom'),
(u'Economía', u'http://periodismohumano.com/seccion/economia/feed/atom'),
(u'Migración', u'http://periodismohumano.com/seccion/migracion/feed/atom'),
(u'Mujer', u'http://periodismohumano.com/seccion/mujer/feed/atom'),
(u'En conflicto', u'http://periodismohumano.com/seccion/en-conflicto/feed/atom'),
(u'Culturas', u'http://periodismohumano.com/seccion/culturas/feed/atom'),
(u'Cooperación', u'http://periodismohumano.com/seccion/cooperacion/feed/atom'),
# Enfoques
(u'P+HD (Redacción)',u'http://pmasdh.periodismohumano.com/feed/atom'),
(u'Alianzas (Leila Nachawati)', u'http://alianzas.periodismohumano.com/feed/atom'),
(u'Con Papeles (Javier Galparsoso)', u'http://conpapeles.periodismohumano.com/feed/atom'),
(u'Consume y Muere (Xóse A. López)', u'http://consumeymuere.periodismohumano.com/feed/atom'),
(u'El Gran Juego (Carlos Sardiña)', u'http://elgranjuego.periodismohumano.com/feed/atom'),
(u'El Minotauro Anda Suelto (Olga Rodríguez)', u'http://minotauro.periodismohumano.com/feed/atom'),
(u'Fronteras (Juan José Téllez)', u'http://tellez.periodismohumano.com/feed/atom'),
(u'Inquietudes Bárbaras (Luís García Montero)', u'http://garciamontero.periodismohumano.com/feed/atom'),
(u'La Madeja de Ariana (Ariadna Alvarado)', u'http://ariana.periodismohumano.com/feed/atom'),
(u'Pandoras Invisibles (Helena Maleno)', u'http://pandoras.periodismohumano.com/feed/atom'),
(u'Ruedas de Molino (Luis Acebal)',u'http://ruedasdemolino.periodismohumano.com/feed/atom'),
(u'Toma la Palabra', u'http://tomalapalabra.periodismohumano.com/feed/atom'),
(u'Tras la Política (David Martos)', u'http://traslapolitica.periodismohumano.com/feed/atom'),
# Sociedad Civil
(u'Amnistía Internacional', u'http://amnistiainternacional.periodismohumano.com/feed/atom'),
(u'Greenpeace', u'http://greenpeace.periodismohumano.com/feed/atom'),
(u'Médicos sin Fronteras', u'http://msf.periodismohumano.com/feed/atom'),
# Periodismo Ciudadano
(u'Bottup', u'http://bottup.periodismohumano.com/feed/atom')
]
preprocess_regexps = [
# Eliminamos el título de la categoría
(re.compile(r'<h2 class="category cat-title.*?</h2>', re.DOTALL|re.IGNORECASE), lambda m: ''),
# Indicamos que antes había un vídeo (que en un ebook quizás no se vea)
(re.compile(r'<param name="movie"', re.DOTALL|re.IGNORECASE), lambda match: '<small>[Video] </small><param name="movie"')
]
Now a couple of questions. The license of the web page is Creative Commons, and I'd like to show it on the final document. Is there any way, o do you suggest any alternative?
Also, I am trying to commit the recipe to the Calibre main development as said
here, but it seems like they changed the bug track system. How can I send the recipe now?
If somebody has any suggestion, feel free to say it (simple ones, please, I am a newbie!)
Cheers
Tito HX