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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.nieuwsblad.be
  7. '''
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9. from calibre.ebooks.BeautifulSoup import Tag
  10.  
  11. class DeGentenaarOnline(BasicNewsRecipe):
  12.     title                 = 'De Gentenaar'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'News from Belgium in Dutch'
  15.     publisher             = 'De Gentenaar'
  16.     category              = 'news, politics, Belgium'
  17.     oldest_article        = 2
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     encoding              = 'utf-8'
  22.     language = 'nl_BE'
  23.  
  24.     lang                  = 'nl-BE'
  25.     direction             = 'ltr'
  26.  
  27.     html2lrf_options = [
  28.                           '--comment'  , description
  29.                         , '--category' , category
  30.                         , '--publisher', publisher
  31.                         ]
  32.  
  33.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em} "'
  34.  
  35.     keep_only_tags = [dict(name='span', attrs={'id':['lblArticleTitle','lblArticleIntroduction','lblArticleMainText']})]
  36.     remove_tags    = [dict(name=['embed','object'])]
  37.  
  38.  
  39.  
  40.     feeds = [
  41.               (u'Snelnieuws' , u'http://feeds.nieuwsblad.be/nieuws/snelnieuws'     )
  42.              ,(u'Binnenland' , u'http://feeds.nieuwsblad.be/nieuws/binnenland'     )
  43.              ,(u'Buitenland' , u'http://feeds.nieuwsblad.be/nieuwsblad/buitenland' )
  44.              ,(u'Economie'   , u'http://feeds.nieuwsblad.be/economie/home'         )
  45.              ,(u'Economie'   , u'http://feeds.nieuwsblad.be/economie/home'         )
  46.              ,(u'Algemeen'   , u'http://feeds.nieuwsblad.be/life/algemeen'         )
  47.              ,(u'Film'       , u'http://feeds.nieuwsblad.be/life/film'             )
  48.              ,(u'Boek'       , u'http://feeds.nieuwsblad.be/life/boeken'           )
  49.              ,(u'Muziek'     , u'http://feeds.nieuwsblad.be/life/muziek'           )
  50.              ,(u'Podium'     , u'http://feeds.nieuwsblad.be/life/podium'           )
  51.              ,(u'TV & radio' , u'http://feeds.nieuwsblad.be/life/tv'               )
  52.             ]
  53.  
  54.     def print_version(self, url):
  55.         return url.replace('/Detail.aspx?articleid','/PrintArticle.aspx?ArticleID')
  56.  
  57.     def get_article_url(self, article):
  58.         return article.get('guid',  None)
  59.  
  60.     def preprocess_html(self, soup):
  61.         del soup.body['onload']
  62.         for item in soup.findAll(style=True):
  63.             del item['style']
  64.         for item in soup.findAll('span'):
  65.             item.name='div'
  66.             if item.has_key('id') and item['id'] == 'lblArticleTitle':
  67.                item.name='h3'
  68.  
  69.         soup.html['lang']     = self.lang
  70.         soup.html['dir' ]     = self.direction
  71.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  72.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  73.         soup.head.insert(0,mlang)
  74.         soup.head.insert(1,mcharset)
  75.         return soup
  76.  
  77.