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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. dw-world.de
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class DeutscheWelle_bs(BasicNewsRecipe):
  11.     title                 = 'Deutsche Welle'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Vijesti iz Njemacke i svijeta'
  14.     publisher             = 'Deutsche Welle'
  15.     category              = 'news, politics, Germany'
  16.     oldest_article        = 1
  17.     max_articles_per_feed = 100
  18.     use_embedded_content  = False
  19.     no_stylesheets        = True
  20.     language              = 'bs'
  21.     publication_type      = 'newsportal'
  22.     remove_empty_feeds    = True
  23.     masthead_url          = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif'
  24.     extra_css             = """
  25.                                 @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
  26.                                 body{font-family: Arial,sans1,sans-serif}
  27.                                 img{margin-top: 0.5em; margin-bottom: 0.2em; display: block}
  28.                                 .caption{font-size: x-small; display: block; margin-bottom: 0.4em}
  29.                             """
  30.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  31.  
  32.  
  33.     conversion_options = {
  34.                           'comment'  : description
  35.                         , 'tags'     : category
  36.                         , 'publisher': publisher
  37.                         , 'language' : language
  38.                         }
  39.  
  40.     remove_tags = [
  41.                      dict(name=['iframe','embed','object','form','base','meta','link'])
  42.                     ,dict(attrs={'class':'actionFooter'})
  43.                   ]
  44.     keep_only_tags=[dict(attrs={'class':'ArticleDetail detail'})]
  45.     remove_attributes = ['height','width','onclick','border','lang']
  46.  
  47.     feeds          = [
  48.                         (u'Politika'         , u'http://rss.dw-world.de/rdf/rss-bos-pol')
  49.                        ,(u'Evropa'           , u'http://rss.dw-world.de/rdf/rss-bos-eu' )
  50.                        ,(u'Kiosk'            , u'http://rss.dw-world.de/rdf/rss-bos-eu' )
  51.                        ,(u'Ekonomija i Nuka' , u'http://rss.dw-world.de/rdf/rss-bos-eco')
  52.                        ,(u'Kultura'          , u'http://rss.dw-world.de/rdf/rss-bos-cul')
  53.                        ,(u'Sport'            , u'http://rss.dw-world.de/rdf/rss-bos-sp' )
  54.                      ]
  55.  
  56.     def print_version(self, url):
  57.         artl = url.rpartition('/')[2]
  58.         return 'http://www.dw-world.de/popups/popup_printcontent/' + artl
  59.  
  60.     def preprocess_html(self, soup):
  61.         for item in soup.findAll('a'):
  62.             limg = item.find('img')
  63.             if item.string is not None:
  64.                str = item.string
  65.                item.replaceWith(str)
  66.             else:
  67.                if limg:
  68.                   item.name = 'div'
  69.                   del item['href']
  70.                   if item.has_key('target'):
  71.                      del item['target']
  72.                else:
  73.                    str = self.tag_to_string(item)
  74.                    item.replaceWith(str)
  75.         return soup
  76.  
  77.