|
|
#1 |
|
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Mar 2011
Device: Kindle v3
|
Recipe for Periodismo Humano
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"')
]
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 |
|
|
|
|
|
#2 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
You can add it to the description to show it before the recipe is used. To add content, use BeautifulSoup and Tag to add a tag or you can modify an existing tag in preprocess_html
|
|
|
|
| Advert | |
|
|
![]() |
| Tags |
| periodismo humano, recipe |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Recipe works when mocked up as Python file, fails when converted to Recipe | ode | Recipes | 7 | 09-04-2011 05:57 AM |
| new recipe | marbs | Recipes | 0 | 11-24-2010 05:59 AM |
| Recipe help | kool | Recipes | 3 | 10-22-2010 04:34 PM |
| New recipe | kiklop74 | Recipes | 0 | 10-05-2010 05:41 PM |
| New recipe | kiklop74 | Recipes | 0 | 10-01-2010 03:42 PM |