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_hr.recipe < prev    next >
Text File  |  2011-09-09  |  3KB  |  75 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_hr(BasicNewsRecipe):
  11.     title                 = 'Deutsche Welle'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Vesti 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              = 'hr'
  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'Svijet'   , u'http://rss.dw-world.de/rdf/rss-cro-svijet')
  49.                        ,(u'Europa'   , u'http://rss.dw-world.de/rdf/rss-cro-eu'    )
  50.                        ,(u'Njemacka' , u'http://rss.dw-world.de/rdf/rss-cro-ger'   )
  51.                        ,(u'Vijesti'  , u'http://rss.dw-world.de/rdf/rss-cro-all'   )
  52.                      ]
  53.  
  54.     def print_version(self, url):
  55.         artl = url.rpartition('/')[2]
  56.         return 'http://www.dw-world.de/popups/popup_printcontent/' + artl
  57.  
  58.     def preprocess_html(self, soup):
  59.         for item in soup.findAll('a'):
  60.             limg = item.find('img')
  61.             if item.string is not None:
  62.                str = item.string
  63.                item.replaceWith(str)
  64.             else:
  65.                if limg:
  66.                   item.name = 'div'
  67.                   del item['href']
  68.                   if item.has_key('target'):
  69.                      del item['target']
  70.                else:
  71.                    str = self.tag_to_string(item)
  72.                    item.replaceWith(str)
  73.         return soup
  74.  
  75.