Debian Codegraph @

recipes/rts.recipe

raw
1 #!/usr/bin/env python
2
3 __license__ = 'GPL v3'
4 __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
5
6 '''
7 www.rts.rs
8 '''
9
10 import re
11
12 from calibre.ebooks.BeautifulSoup import Tag
13 from calibre.web.feeds.news import BasicNewsRecipe
14
15
16 def new_tag(soup, name, attrs=()):
17 impl = getattr(soup, 'new_tag', None)
18 if impl is not None:
19 return impl(name, attrs=dict(attrs))
20 return Tag(soup, name, attrs=attrs or None)
21
22
23 class RTS(BasicNewsRecipe):
24 title = 'RTS: Vesti'
25 __author__ = 'Darko Miletic'
26 description = 'News from Serbia'
27 publisher = 'RTS'
28 category = 'news, politics, Serbia, RTS'
29 no_stylesheets = True
30 encoding = 'utf-8'
31 use_embedded_content = True
32 language = 'sr'
33
34 lang = 'sr-Latn-RS'
35 extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} body{font-family: serif1, serif} .article_description{font-family: serif1, serif}' # noqa: E501
36
37 conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': lang, 'pretty_print': True}
38
39 preprocess_regexps = [(re.compile('\u0110'), lambda match: '\u00d0')] # noqa: RUF039
40
41 feeds = [
42 ('Vesti', 'http://www.rts.rs/page/stories/sr/rss.html'),
43 ('Srbija', 'http://www.rts.rs/page/stories/sr/rss/9/Srbija.html'),
44 ('Region', 'http://www.rts.rs/page/stories/sr/rss/11/Region.html'),
45 ('Svet', 'http://www.rts.rs/page/stories/sr/rss/10/Svet.html'),
46 ('Hronika', 'http://www.rts.rs/page/stories/sr/rss/135/Hronika.html'),
47 ('Drustvo', 'http://www.rts.rs/page/stories/sr/rss/125/Dru%C5%A1tvo.html'),
48 ('Ekonomija', 'http://www.rts.rs/page/stories/sr/rss/13/Ekonomija.html'),
49 ('Nauka', 'http://www.rts.rs/page/stories/sr/rss/14/Nauka.html'),
50 ('Kultura', 'http://www.rts.rs/page/stories/sr/rss/16/Kultura.html'),
51 ('Zanimljivosti', 'http://www.rts.rs/page/stories/sr/rss/15/Zanimljivosti.html'),
52 ('Sport', 'http://www.rts.rs/page/sport/sr/rss.html'),
53 ]
54
55 def preprocess_html(self, soup):
56 soup.html['xml:lang'] = self.lang
57 soup.html['lang'] = self.lang
58 mlang = new_tag(soup, 'meta', [('http-equiv', 'Content-Language'), ('content', self.lang)])
59 mcharset = new_tag(soup, 'meta', [('http-equiv', 'Content-Type'), ('content', 'text/html; charset=UTF-8')])
60 soup.head.insert(0, mlang)
61 soup.head.insert(1, mcharset)
62 return self.adeify_images(soup)