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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = u'2010, Tomasz Dlugosz <tomek3d@gmail.com>'
  5. '''
  6. rmf24.pl
  7. '''
  8.  
  9. import re
  10. from calibre.web.feeds.news import BasicNewsRecipe
  11.  
  12. class RMF24_opinie(BasicNewsRecipe):
  13.     title          = u'Rmf24.pl - Opinie'
  14.     description    = u'Blogi, wywiady i komentarze ze strony rmf24.pl'
  15.     language = 'pl'
  16.     oldest_article = 7
  17.     max_articles_per_feed = 100
  18.     __author__ = u'Tomasz D\u0142ugosz'
  19.     no_stylesheets = True
  20.     remove_javascript = True
  21.  
  22.     feeds          = [(u'Blogi', u'http://www.rmf24.pl/opinie/blogi/feed'),
  23.                       (u'Kontrwywiad', u'http://www.rmf24.pl/opinie/wywiady/kontrwywiad/feed'),
  24.                       (u'Przes\u0142uchanie', u'http://www.rmf24.pl/opinie/wywiady/przesluchanie/feed'),
  25.                       (u'Komentarze', u'http://www.rmf24.pl/opinie/komentarze/feed')]
  26.  
  27.     keep_only_tags = [
  28.         dict(name='div', attrs={'class':'box articleSingle print'}),
  29.         dict(name='div', attrs={'class':'box articleSingle print singleCommentary'}),
  30.         dict(name='div', attrs={'class':'box articleSingle print blogSingleEntry'})]
  31.  
  32.     remove_tags = [
  33.         dict(name='div', attrs={'class':'toTop'}),
  34.         dict(name='div', attrs={'class':'category'}),
  35.         dict(name='div', attrs={'class':'REMOVE'}),
  36.         dict(name='div', attrs={'class':'embed embedAd'})]
  37.  
  38.     extra_css = '''
  39.         h1 { font-size: 1.2em; }
  40.     '''
  41.  
  42.     # thanks to Kovid Goyal
  43.     def get_article_url(self, article):
  44.         link = article.get('link')
  45.         if '/audio,aId' not in link:
  46.             return link
  47.  
  48.     preprocess_regexps = [
  49.         (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) for i in 
  50.         [
  51.             (r'<h2>Zdj.cie</h2>', lambda match: ''),
  52.             (r'embed embed(Left|Right|Center) articleEmbed(Audio|Wideo articleEmbedVideo|ArticleFull|ArticleTitle|ArticleListTitle|AlbumHorizontal)">', lambda match: 'REMOVE">'),
  53.             (r'<a href="http://www.facebook.com/pages/RMF24pl/.*?>RMF24.pl</a> on Facebook</div>', lambda match: '</div>')
  54.         ]
  55.     ]
  56.