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

  1.  
  2. __license__   = 'GPL v3'
  3. __copyright__ = '2008-2011, Darko Miletic <darko.miletic at gmail.com>'
  4. '''
  5. b92.net
  6. '''
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class B92(BasicNewsRecipe):
  11.     title                 = 'B92'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Najnovije vesti iz Srbije, regiona i sveta, aktuelne teme iz sveta politike, ekonomije, drustva, foto galerija, kolumne'    
  14.     publisher             = 'B92'
  15.     category              = 'news, politics, Serbia'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 100
  18.     no_stylesheets        = True
  19.     use_embedded_content  = False
  20.     encoding              = 'cp1250'
  21.     language              = 'sr'
  22.     publication_type      = 'newsportal'
  23.     masthead_url          = 'http://www.b92.net/images/fp/logo.gif'
  24.     extra_css             = """ 
  25.                                 @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
  26.                                 @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
  27.                                 body{font-family: Arial,Helvetica,sans1,sans-serif} 
  28.                                 .articledescription{font-family: serif1, serif}
  29.                                 .article-info2,.article-info1{text-transform: uppercase; font-size: small}
  30.                             """
  31.     
  32.     conversion_options = {
  33.                           'comment'  : description
  34.                         , 'tags'     : category
  35.                         , 'publisher': publisher
  36.                         , 'language' : language
  37.                         , 'linearize_tables' : True
  38.                         }
  39.     
  40.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  41.     
  42.     keep_only_tags    = [dict(attrs={'class':['article-info1','article-text']})]
  43.     remove_attributes = ['width','height','align','hspace','vspace','border']
  44.     remove_tags       = [dict(name=['embed','link','base','meta'])]
  45.  
  46.     feeds          = [
  47.                         (u'Vesti'      , u'http://www.b92.net/info/rss/vesti.xml'     )
  48.                        ,(u'Biz'        , u'http://www.b92.net/info/rss/biz.xml'       )
  49.                        ,(u'Sport'      , u'http://www.b92.net/info/rss/sport.xml'     )
  50.                        ,(u'Zivot'      , u'http://www.b92.net/info/rss/zivot.xml'     )
  51.                        ,(u'Kultura'    , u'http://www.b92.net/info/rss/kultura.xml'   )
  52.                        ,(u'Automobili' , u'http://www.b92.net/info/rss/automobili.xml')
  53.                        ,(u'Tehnopolis' , u'http://www.b92.net/info/rss/tehnopolis.xml')
  54.                      ]
  55.  
  56.     def preprocess_html(self, soup):
  57.         for item in soup.findAll(style=True):
  58.             del item['style']
  59.         for alink in soup.findAll('a'):
  60.             if alink.string is not None:
  61.                tstr = alink.string
  62.                alink.replaceWith(tstr)            
  63.         return soup
  64.