Debian Codegraph @

recipes/neviditelny_pes.recipe

raw
1 import re
2
3 from calibre.web.feeds.recipes import BasicNewsRecipe
4
5
6 class pesRecipe(BasicNewsRecipe):
7 __author__ = 'bubak'
8 title = 'Neviditelný pes'
9 publisher = ''
10 description = 'Neviditelný pes'
11 oldest_article = 1
12 max_articles_per_feed = 20
13 use_embedded_content = False
14 remove_empty_feeds = True
15
16 feeds = [('Neviditelný pes', 'https://neviditelnypes.lidovky.cz/rss.aspx')]
17
18 language = 'cs'
19 cover_url = 'http://g.zpravy.cz/o/pes/logo_pes.jpg'
20 remove_javascript = True
21 no_stylesheets = True
22 extra_css = '''
23 '''
24
25 remove_tags = [
26 dict(name='ul', attrs={'id': 'main-nav'}),
27 dict(name='div', attrs={'class': ['psi-hlava', 'list-art', 'links', 'col-b', 'footer', 'pes-tag-cloud']}),
28 dict(name='div', attrs={'id': 'portal-g0'}),
29 ]
30 remove_tags_before = dict(name='div', attrs={'id': 'art-full'})
31 remove_tags_after = dict(name='div', attrs={'class': 'authors'})
32
33 # move the author forward
34 preprocess_regexps = [
35 (
36 re.compile(r'(<h1 class.*?</h1>)(.*?)(<(?:span|a) class="name".*?>)(.*?)<', re.DOTALL | re.IGNORECASE),
37 lambda m: m.group(1) + '<b>' + m.group(4) + '</b>' + m.group(2) + m.group(3) + m.group(4) + '<',
38 ),
39 # remove links
40 (re.compile(r'<a\s[^>]*>([^<]*)</a>', re.DOTALL | re.IGNORECASE), lambda match: match.group(1)),
41 ]
42
43 def image_url_processor(self, baseurl, url):
44 if url.startswith('//'):
45 return 'http:' + url
46 if url.startswith('file://'):
47 return url.replace('file://', 'http://')
48 return url