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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5.  
  6. '''
  7. www.hrt.hr
  8. '''
  9.  
  10. import re
  11. from calibre.web.feeds.news import BasicNewsRecipe
  12. from calibre.ebooks.BeautifulSoup import Tag
  13.  
  14. class HRT(BasicNewsRecipe):
  15.     title                 = 'HRT: Vesti'
  16.     __author__            = 'Darko Miletic'
  17.     description           = 'News from Croatia'
  18.     publisher             = 'HRT'
  19.     category              = 'news, politics, Croatia, HRT'
  20.     no_stylesheets        = True
  21.     encoding              = 'utf-8'
  22.     use_embedded_content  = False
  23.     language = 'hr'
  24.  
  25.     lang                  = 'hr-HR'
  26.     extra_css = '''@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
  27.                     body{font-family: serif1, serif} .article_description{font-family: serif1, serif}
  28.                    .news-single-timedata{color:#20558A; font-size:x-small;}
  29.                    .nsTitle{color:#20558A; font-size:large; font-weight:bold;}
  30.                    a{color:#20558A;}
  31.                    .external-link-new-window{color:#20558A;}
  32.  
  33.                 '''
  34.  
  35.     conversion_options = {
  36.                           'comment'          : description
  37.                         , 'tags'             : category
  38.                         , 'publisher'        : publisher
  39.                         , 'language'         : lang
  40.                         , 'pretty_print'     : True
  41.                         }
  42.  
  43.  
  44.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  45.  
  46.  
  47.     keep_only_tags     = [dict(name='div', attrs={'class':'bigVijest'})]
  48.  
  49.     remove_tags = [dict(name=['object','link','embed'])]
  50.  
  51.     remove_tags_after  = dict(name='div', attrs={'class':'nsAuthor'})
  52.  
  53.     feeds = [
  54.                (u'Vijesti'             , u'http://www.hrt.hr/?id=316&type=100&rss=vijesti'     )
  55.               ,(u'Sport'               , u'http://www.hrt.hr/?id=316&type=100&rss=sport'       )
  56.               ,(u'Zabava'              , u'http://www.hrt.hr/?id=316&type=100&rss=zabava'      )
  57.               ,(u'Filmovi i serije'    , u'http://www.hrt.hr/?id=316&type=100&rss=filmovi'     )
  58.               ,(u'Dokumentarni program', u'http://www.hrt.hr/?id=316&type=100&rss=dokumentarci')
  59.               ,(u'Glazba'              , u'http://www.hrt.hr/?id=316&type=100&rss=glazba'      )
  60.               ,(u'Kultura'             , u'http://www.hrt.hr/?id=316&type=100&rss=kultura'     )
  61.               ,(u'Mladi'               , u'http://www.hrt.hr/?id=316&type=100&rss=mladi'       )
  62.               ,(u'Manjine'             , u'http://www.hrt.hr/?id=316&type=100&rss=manjine'     )
  63.               ,(u'Radio'               , u'http://www.hrt.hr/?id=316&type=100&rss=radio'       )
  64.             ]
  65.  
  66.     def preprocess_html(self, soup):
  67.         soup.html['xml:lang'] = self.lang
  68.         soup.html['lang']     = self.lang
  69.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  70.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
  71.         soup.head.insert(0,mlang)
  72.         soup.head.insert(1,mcharset)
  73.         for item in soup.findAll(style=True):
  74.             del item['style']
  75.         return self.adeify_images(soup)
  76.