home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3988 < prev    next >
Encoding:
Text File  |  2009-10-14  |  3.3 KB  |  72 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. politika.rs
  7. '''
  8. import re
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class Politika(BasicNewsRecipe):
  13.     title                 = 'Politika Online'
  14.     __author__            = 'Darko Miletic'
  15.     description           = 'Najstariji dnevni list na Balkanu'
  16.     publisher             = 'Politika novine i Magazini d.o.o'
  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.     remove_javascript     = True
  23.     encoding              = 'utf8'
  24.     language = 'sr'
  25.  
  26.     lang                 = 'sr-Latn-RS'
  27.     direction            = 'ltr'
  28.     extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} body{font-family: serif1, serif} .article_description{font-family: sans1, sans-serif}'
  29.  
  30.     conversion_options = {
  31.                           'comment'          : description
  32.                         , 'tags'             : category
  33.                         , 'publisher'        : publisher
  34.                         , 'language'         : lang
  35.                         , 'pretty_print'     : True
  36.                         }
  37.  
  38.  
  39.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  40.  
  41.     keep_only_tags     = [dict(name='div', attrs={'class':'content_center_border'})]
  42.  
  43.     remove_tags = [
  44.                     dict(name='div', attrs={'class':['send_print','txt-komentar']})
  45.                    ,dict(name=['object','link','a'])
  46.                    ,dict(name='h1', attrs={'class':'box_header-tags'})
  47.                   ]
  48.  
  49.  
  50.     feeds          = [
  51.                          (u'Politika'             , u'http://www.politika.rs/rubrike/Politika/index.1.lt.xml'             )
  52.                         ,(u'Svet'                 , u'http://www.politika.rs/rubrike/Svet/index.1.lt.xml'                 )
  53.                         ,(u'Redakcijski komentari', u'http://www.politika.rs/rubrike/redakcijski-komentari/index.1.lt.xml')
  54.                         ,(u'Pogledi'              , u'http://www.politika.rs/pogledi/index.lt.xml'                        )
  55.                         ,(u'Pogledi sa strane'    , u'http://www.politika.rs/rubrike/Pogledi-sa-strane/index.1.lt.xml'    )
  56.                         ,(u'Tema dana'            , u'http://www.politika.rs/rubrike/tema-dana/index.1.lt.xml'            )
  57.                         ,(u'Kultura'              , u'http://www.politika.rs/rubrike/Kultura/index.1.lt.xml'              )
  58.                         ,(u'Zivot i stil'         , u'http://www.politika.rs/rubrike/zivot-i-stil/index.1.lt.xml'         )
  59.                      ]
  60.  
  61.     def preprocess_html(self, soup):
  62.         soup.html['lang'] = self.lang
  63.         soup.html['dir' ] = self.direction
  64.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  65.         soup.head.insert(0,mlang)
  66.         for item in soup.findAll(style=True):
  67.             del item['style']
  68.         ftag = soup.find('div',attrs={'class':'content_center_border'})
  69.         if ftag.has_key('align'):
  70.            del ftag['align']
  71.         return self.adeify_images(soup)
  72.