Debian Codegraph @

recipes/seznamzpravy.recipe

raw
1 import re
2
3 from calibre.web.feeds.recipes import BasicNewsRecipe
4
5
6 class seznamzpravyRecipe(BasicNewsRecipe):
7 __author__ = 'bubak'
8 title = 'Seznam zprávy'
9 description = 'seznamzpravy.cz'
10 oldest_article = 1
11 max_articles_per_feed = 20
12
13 feeds = [('Nejnovější články', 'http://www.seznamzpravy.cz/rss')]
14
15 language = 'cs'
16 cover_url = 'https://www.seznam.cz/media/img/logo_v2.svg'
17 remove_javascript = True
18 no_stylesheets = True
19 use_embedded_content = False
20
21 remove_tags_before = dict(name='div', attrs={'class': ['c_fT']})
22 remove_tags = [
23 dict(
24 name='div',
25 attrs={
26 'class': [
27 'g_c9',
28 'd_eQ',
29 'd_eS',
30 'e-aJ',
31 'g_dE',
32 'XXXg_bj',
33 'd_e3',
34 'g_bv',
35 'd_eT',
36 'h_hA',
37 'g_bv g_bt',
38 'e_S g_bz',
39 'g_ei',
40 'e_S',
41 'c_fP',
42 'c_ix',
43 ]
44 },
45 ),
46 dict(
47 name='div',
48 attrs={
49 'data-dot': [
50 'ogm-header',
51 'ogm-ribbon',
52 'ogm-actual-box',
53 'ogm-main-media',
54 'mol-embed',
55 'ogm-breadcrumb-navigation',
56 'ogm-related-documents',
57 'ogm-related-tags',
58 'mol-articles-container',
59 'ogm-document-timeline',
60 'mol-document-links',
61 ]
62 },
63 ),
64 dict(name='div', attrs={'data-e2e': ['mol-advert']}),
65 dict(name='header', attrs={'data-dot': ['tpl-mainHeader']}),
66 dict(name='h6', attrs={'id': ['accessibility-article', 'accessibility-header', 'accessibility-content']}),
67 dict(name='div', attrs={'class': re.compile(r'breadcrumb', re.IGNORECASE)}),
68 dict(name='div', attrs={'data-dot': re.compile(r'ogm-date', re.IGNORECASE)}),
69 dict(name='svg'),
70 dict(name='figure'),
71 dict(name='aside'),
72 ]
73 remove_tags_after = dict(name='div', attrs={'data-dot': 'ogm-related-tags'})
74
75 visited_urls = {}
76
77 def get_article_url(self, article):
78 url = BasicNewsRecipe.get_article_url(self, article)
79 if url in self.visited_urls:
80 self.log.debug('Ignoring duplicate: ' + url)
81 return None
82 else:
83 self.visited_urls[url] = True
84 self.log.debug('Accepting: ' + url)
85 return url
86
87 def populate_article_metadata(self, article, soup, first):
88 self.log('Article date ', article.date)