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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5.  
  6. '''
  7. nacional.hr
  8. '''
  9.  
  10. import re
  11. from calibre.web.feeds.recipes import BasicNewsRecipe
  12. from calibre.ebooks.BeautifulSoup import Tag
  13.  
  14. class NacionalCro(BasicNewsRecipe):
  15.     title                 = 'Nacional - Hr'
  16.     __author__            = 'Darko Miletic'
  17.     description           = "news from Croatia"
  18.     publisher             = 'Nacional.hr'
  19.     category              = 'news, politics, Croatia'
  20.     oldest_article        = 2
  21.     max_articles_per_feed = 100
  22.     delay                 = 4
  23.     no_stylesheets        = True
  24.     encoding              = 'utf-8'
  25.     use_embedded_content  = False
  26.     language = 'hr'
  27.  
  28.     lang                 = 'hr-HR'
  29.     direction            = 'ltr'
  30.  
  31.     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}'
  32.  
  33.     conversion_options = {
  34.                           'comment'          : description
  35.                         , 'tags'             : category
  36.                         , 'publisher'        : publisher
  37.                         , 'language'         : lang
  38.                         , 'pretty_print'     : True
  39.                         }
  40.  
  41.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  42.  
  43.     remove_tags = [dict(name=['object','link','embed'])]
  44.  
  45.     feeds = [(u'Najnovije Vijesti', u'http://www.nacional.hr/rss')]
  46.  
  47.     def preprocess_html(self, soup):
  48.         soup.html['lang'] = self.lang
  49.         soup.html['dir' ] = self.direction
  50.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  51.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
  52.         soup.head.insert(0,mlang)
  53.         soup.head.insert(1,mcharset)
  54.         for item in soup.findAll(style=True):
  55.             del item['style']
  56.         return soup
  57.  
  58.     def print_version(self, url):
  59.         rest, sep, disc = url.rpartition('/')
  60.         return rest.replace('/clanak/','/clanak/print/')
  61.  
  62.