~ubuntu-branches/ubuntu/karmic/calibre/karmic-updates

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_rts.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-06-06 17:18:02 UTC
  • mfrom: (1.4.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090606171802-fcu5dzgkxygn79y6
Tags: 0.5.14+dfsg-1
* New upstream release.
* debian/rules, get-orig-source: Do not unpack newly generated orig tarball
  if we don't have unpackaged upstream sources in the tree (such as when
  building with bzr-buildpackage).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
from calibre.web.feeds.news import BasicNewsRecipe
 
12
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
 
13
 
 
14
class RTS(BasicNewsRecipe):
 
15
    title                 = 'RTS: Vesti'
 
16
    __author__            = 'Darko Miletic'
 
17
    description           = 'News from Serbia'
 
18
    publisher             = 'RTS'
 
19
    category              = 'news, politics, Serbia, RTS'
 
20
    no_stylesheets        = True
 
21
    encoding              = 'utf-8'
 
22
    use_embedded_content  = True
 
23
    language              = _("Serbian")
 
24
    lang                  = 'sr-Latn-RS'
 
25
    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}'
 
26
    
 
27
    html2lrf_options = [
 
28
                          '--comment', description
 
29
                        , '--category', category
 
30
                        , '--publisher', publisher
 
31
                        ]
 
32
    
 
33
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"'
 
34
 
 
35
    
 
36
    preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
 
37
 
 
38
    feeds = [
 
39
               (u'Vesti'         , u'http://www.rts.rs/page/stories/sr/rss.html'                 )
 
40
              ,(u'Srbija'        , u'http://www.rts.rs/page/stories/sr/rss/9/Srbija.html'        )
 
41
              ,(u'Region'        , u'http://www.rts.rs/page/stories/sr/rss/11/Region.html'       )
 
42
              ,(u'Svet'          , u'http://www.rts.rs/page/stories/sr/rss/10/Svet.html'         )
 
43
              ,(u'Hronika'       , u'http://www.rts.rs/page/stories/sr/rss/135/Hronika.html'     )
 
44
              ,(u'Drustvo'       , u'http://www.rts.rs/page/stories/sr/rss/125/Dru%C5%A1tvo.html')
 
45
              ,(u'Ekonomija'     , u'http://www.rts.rs/page/stories/sr/rss/13/Ekonomija.html'    )
 
46
              ,(u'Nauka'         , u'http://www.rts.rs/page/stories/sr/rss/14/Nauka.html'        )
 
47
              ,(u'Kultura'       , u'http://www.rts.rs/page/stories/sr/rss/16/Kultura.html'      )
 
48
              ,(u'Zanimljivosti' , u'http://www.rts.rs/page/stories/sr/rss/15/Zanimljivosti.html')
 
49
              ,(u'Sport'         , u'http://www.rts.rs/page/sport/sr/rss.html'                   )
 
50
            ]
 
51
 
 
52
    def preprocess_html(self, soup):
 
53
        soup.html['xml:lang'] = self.lang
 
54
        soup.html['lang']     = self.lang
 
55
        mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
 
56
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
 
57
        soup.head.insert(0,mlang)
 
58
        soup.head.insert(1,mcharset)
 
59
        return self.adeify_images(soup)
 
60