home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_280 / 24sata.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. 24sata.hr
  8. '''
  9.  
  10. import re
  11. from calibre.web.feeds.recipes import BasicNewsRecipe
  12. from calibre.ebooks.BeautifulSoup import Tag
  13.  
  14. class Cro24Sata(BasicNewsRecipe):
  15.     title                 = '24 Sata - Hr'
  16.     __author__            = 'Darko Miletic'
  17.     description           = "News Portal from Croatia"
  18.     publisher             = '24sata.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.  
  30.     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}'
  31.  
  32.     conversion_options = {
  33.                           'comment'          : description
  34.                         , 'tags'             : category
  35.                         , 'publisher'        : publisher
  36.                         , 'language'         : lang
  37.                         , 'pretty_print'     : True
  38.                         }
  39.  
  40.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  41.  
  42.     remove_tags = [
  43.                     dict(name=['object','link','embed'])
  44.                    ,dict(name='table', attrs={'class':'enumbox'})
  45.                   ]
  46.  
  47.     feeds = [(u'Najnovije Vijesti', u'http://www.24sata.hr/index.php?cmd=show_rss&action=novo')]
  48.  
  49.     def preprocess_html(self, soup):
  50.         soup.html['lang']     = self.lang
  51.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  52.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
  53.         soup.head.insert(0,mlang)
  54.         soup.head.insert(1,mcharset)
  55.         for item in soup.findAll(style=True):
  56.             del item['style']
  57.         return soup
  58.  
  59.     def print_version(self, url):
  60.         return url + '&action=ispis'
  61.  
  62.