Debian Codegraph @

recipes/novosti.recipe

raw
1 __license__ = 'GPL v3'
2 __copyright__ = '2008-2011, Darko Miletic <darko.miletic at gmail.com>'
3 '''
4 novosti.rs
5 '''
6
7 import re
8
9 from calibre.web.feeds.news import BasicNewsRecipe
10
11
12 class Novosti(BasicNewsRecipe):
13 title = 'Vecernje Novosti'
14 __author__ = 'Darko Miletic'
15 description = 'U početku su bile istinske večernje novine - pokrenute u vreme Tršćanske krize, Italijansko-jugoslovenskog konflikta oko grada Trsta - ali su brzo izrasle u dnevni informativno-politički list, koji već godinama ima najveći tiraž u Srbiji.' # noqa: E501
16 publisher = 'Kompanija Novosti'
17 category = 'news, politics, Serbia'
18 oldest_article = 2
19 max_articles_per_feed = 100
20 no_stylesheets = True
21 use_embedded_content = False
22 encoding = 'utf-8'
23 language = 'sr'
24 publication_type = 'newspaper'
25 masthead_url = 'http://www.novosti.rs/images/basic/logo-print.png'
26 extra_css = ''' @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
27 .article_description,body{font-family: Arial,Helvetica,sans1,sans-serif}
28 .author{font-size: small}
29 .articleLead{font-size: large; font-weight: bold}
30 img{display: block; margin-bottom: 1em; margin-top: 1em}
31 '''
32
33 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language, 'pretty_print': True}
34
35 preprocess_regexps = [(re.compile('\u0110'), lambda match: '\u00d0')] # noqa: RUF039
36
37 keep_only_tags = [dict(attrs={'class': ['articleTitle', 'articleInfo', 'articleLead', 'singlePhoto fl', 'articleBody']})]
38 remove_tags = [dict(name=['embed', 'object', 'iframe', 'base', 'link', 'meta']), dict(name='a', attrs={'class': 'loadComments topCommentsLink'})]
39 remove_attributes = ['lang', 'xmlns:fb']
40
41 feeds = [
42 ('Politika', 'http://www.novosti.rs/rss/2-Sve%20vesti'),
43 ('Drustvo', 'http://www.novosti.rs/rss/1-Sve%20vesti'),
44 ('Ekonomija', 'http://www.novosti.rs/rss/3-Sve%20vesti'),
45 ('Hronika', 'http://www.novosti.rs/rss/4-Sve%20vesti'),
46 ('Dosije', 'http://www.novosti.rs/rss/5-Sve%20vesti'),
47 ('Reportaze', 'http://www.novosti.rs/rss/6-Sve%20vesti'),
48 ('Tehnologije', 'http://www.novosti.rs/rss/35-Sve%20vesti'),
49 ('Zanimljivosti', 'http://www.novosti.rs/rss/26-Sve%20vesti'),
50 ('Auto', 'http://www.novosti.rs/rss/50-Sve%20vesti'),
51 ('Sport', 'http://www.novosti.rs/rss/11|47|12|14|13-Sve%20vesti'),
52 ('Svet', 'http://www.novosti.rs/rss/7-Sve%20vesti'),
53 ('Region', 'http://www.novosti.rs/rss/8-Sve%20vesti'),
54 ('Dijaspora', 'http://www.novosti.rs/rss/9-Sve%20vesti'),
55 ('Spektakl', 'http://www.novosti.rs/rss/10-Sve%20vesti'),
56 ('Kultura', 'http://www.novosti.rs/rss/31-Sve%20vesti'),
57 ('Srbija', 'http://www.novosti.rs/rss/15-Sve%20vesti'),
58 ('Beograd', 'http://www.novosti.rs/rss/16-Sve%20vesti'),
59 ('Zivot+', 'http://www.novosti.rs/rss/24|33|34|25|20|18|32|19-Sve%20vesti'),
60 ('Turizam', 'http://www.novosti.rs/rss/36-Sve%20vesti'),
61 ]
62
63 def preprocess_html(self, soup):
64 for item in soup.findAll(style=True):
65 del item['style']
66 for item in soup.findAll('a'):
67 limg = item.find('img')
68 if item.string is not None:
69 str = item.string
70 item.replaceWith(str)
71 elif limg:
72 item.name = 'div'
73 item.attrs = []
74 else:
75 str = self.tag_to_string(item)
76 item.replaceWith(str)
77 for item in soup.findAll('img', alt=False):
78 item['alt'] = 'image'
79 return soup