home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_280 / krstarica.recipe < prev    next >
Encoding:
Text File  |  2011-09-09  |  3.4 KB  |  67 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. vesti.krstarica.com
  7. '''
  8. import re
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class Krstarica(BasicNewsRecipe):
  12.     title                 = 'Krstarica - Vesti'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'Dnevne vesti iz Srbije i sveta'    
  15.     publisher             = 'Krstarica'
  16.     category              = 'news, politics, Serbia'
  17.     oldest_article        = 1
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     remove_javascript     = True
  22.     encoding              = 'utf-8'
  23.     language = 'sr'
  24.  
  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}"' 
  34.     
  35.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  36.     
  37.     feeds          = [
  38.                         (u'Vesti dana'         , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=aktuelno&lang=0'     )
  39.                        ,(u'Srbija'             , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=scg&lang=0'          )
  40.                        ,(u'Svet'               , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=svet&lang=0'         )
  41.                        ,(u'Politika'           , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=politika&lang=0'     )
  42.                        ,(u'Ekonomija'          , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=ekonomija&lang=0'    )
  43.                        ,(u'Drustvo'            , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=drustvo&lang=0'      )
  44.                        ,(u'Kultura'            , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=kultura&lang=0'      )
  45.                        ,(u'Nauka i Tehnologija', u'http://vesti.krstarica.com/index.php?rss=1&rubrika=nauka&lang=0'        )
  46.                        ,(u'Medicina'           , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=medicina&lang=0'     )
  47.                        ,(u'Sport'              , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=sport&lang=0'        )
  48.                        ,(u'Zanimljivosti'      , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=zanimljivosti&lang=0')
  49.                      ]
  50.  
  51.     def preprocess_html(self, soup):
  52.         mtag = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
  53.         soup.head.insert(0,mtag)
  54.         titletag = soup.find('h4')
  55.         if titletag:
  56.            realtag = titletag.parent.parent
  57.            realtag.extract()
  58.            for item in soup.findAll(['table','center']):
  59.                item.extract()
  60.            soup.body.insert(1,realtag)            
  61.            realtag.name = 'div'
  62.         for item in soup.findAll(style=True):
  63.             del item['style']
  64.         for item in soup.findAll(align=True):
  65.             del item['align']
  66.         return soup
  67.