Debian Codegraph @

recipes/20_minutos.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 __license__ = 'GPL v3'
4 __author__ = 'Luis Hernandez'
5 __copyright__ = 'Luis Hernandez<[email protected]>'
6 __version__ = 'v0.85'
7 __date__ = '31 January 2011'
8
9 '''
10 www.20minutos.es
11 '''
12 import re
13
14 from calibre.web.feeds.news import BasicNewsRecipe
15
16
17 class AdvancedUserRecipe1294946868(BasicNewsRecipe):
18 title = '20 Minutos'
19 publisher = 'Grupo 20 Minutos'
20
21 __author__ = 'Luis Hernandez'
22 description = 'Free spanish newspaper'
23 cover_url = 'http://estaticos.20minutos.es/mmedia/especiales/corporativo/css/img/logotipos_grupo20minutos.gif'
24
25 oldest_article = 2
26 max_articles_per_feed = 100
27
28 remove_javascript = True
29 no_stylesheets = True
30 use_embedded_content = False
31
32 encoding = 'ISO-8859-1'
33 language = 'es'
34 timefmt = '[%a, %d %b, %Y]'
35 remove_empty_feeds = True
36
37 keep_only_tags = [
38 dict(
39 name='div',
40 attrs={
41 'id': [
42 'content',
43 'vinetas',
44 ]
45 },
46 ),
47 dict(name='div', attrs={'class': ['boxed', 'description', 'lead', 'article-content', 'cuerpo estirar']}),
48 dict(name='span', attrs={'class': ['photo-bar']}),
49 dict(name='ul', attrs={'class': ['article-author']}), # noqa: E501
50 ]
51
52 remove_tags_before = dict(name='ul', attrs={'class': ['servicios-sub']})
53 remove_tags_after = dict(name='div', attrs={'class': ['related-news', 'col']})
54
55 remove_tags = [
56 dict(
57 name='ol',
58 attrs={
59 'class': [
60 'navigation',
61 ]
62 },
63 ),
64 dict(name='span', attrs={'class': ['action']}),
65 dict(
66 name='div',
67 attrs={
68 'class': [
69 'twitter comments-list hidden',
70 'related-news',
71 'col',
72 'photo-gallery',
73 'photo-gallery side-art-block',
74 'calendario',
75 'article-comment',
76 'postto estirar',
77 'otras_vinetas estirar',
78 'kment',
79 'user-actions',
80 ]
81 },
82 ),
83 dict(
84 name='div',
85 attrs={
86 'id': [
87 'twitter-destacados',
88 'eco-tabs',
89 'inner',
90 'vineta_calendario',
91 'vinetistas clearfix',
92 'otras_vinetas estirar',
93 'MIN1',
94 'main',
95 'SUP1',
96 'INT',
97 ]
98 },
99 ),
100 dict(name='ul', attrs={'class': ['article-user-actions', 'stripped-list']}),
101 dict(name='ul', attrs={'id': ['site-links']}),
102 dict(name='li', attrs={'class': ['puntuacion', 'enviar', 'compartir']}), # noqa: E501
103 ]
104
105 extra_css = '''
106 p{text-align: justify; font-size: 100%}
107 body{ text-align: left; font-size:100% }
108 h3{font-family: sans-serif; font-size:150%; font-weight:bold; text-align: justify; }
109 '''
110
111 preprocess_regexps = [(re.compile(r'<a href="http://estaticos.*?[0-999]px;" target="_blank">', re.DOTALL), lambda m: '')]
112
113 recipe_specific_options = {
114 'days': {
115 'short': 'Oldest article to download from this news source. In days ',
116 'long': 'For example, 0.5, gives you articles from the past 12 hours',
117 'default': str(oldest_article),
118 }
119 }
120
121 def __init__(self, *args, **kwargs):
122 BasicNewsRecipe.__init__(self, *args, **kwargs)
123 d = self.recipe_specific_options.get('days')
124 if d and isinstance(d, str):
125 self.oldest_article = float(d)
126
127 feeds = [
128 ('Portada', 'http://www.20minutos.es/rss/'),
129 ('Nacional', 'http://www.20minutos.es/rss/nacional/'),
130 ('Internacional', 'http://www.20minutos.es/rss/internacional/'),
131 ('Economia', 'http://www.20minutos.es/rss/economia/'),
132 ('Deportes', 'http://www.20minutos.es/rss/deportes/'),
133 ('Tecnologia', 'http://www.20minutos.es/rss/tecnologia/'),
134 ('Gente - TV', 'http://www.20minutos.es/rss/gente-television/'),
135 ('Motor', 'http://www.20minutos.es/rss/motor/'),
136 ('Salud', 'http://www.20minutos.es/rss/belleza-y-salud/'),
137 ('Viajes', 'http://www.20minutos.es/rss/viajes/'),
138 ('Vivienda', 'http://www.20minutos.es/rss/vivienda/'),
139 ('Empleo', 'http://www.20minutos.es/rss/empleo/'),
140 ('Cine', 'http://www.20minutos.es/rss/cine/'),
141 ('Musica', 'http://www.20minutos.es/rss/musica/'),
142 ('Vinetas', 'http://www.20minutos.es/rss/vinetas/'),
143 ('Comunidad20', 'http://www.20minutos.es/rss/zona20/'),
144 ]