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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. rollingstone.com
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class RollingStone(BasicNewsRecipe):
  11.     title                 = 'Rolling Stone Magazine - free content'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Rolling Stone Magazine features music, album and artist news, movie reviews, political, economic and pop culture commentary, videos, photos, and more.'
  14.     publisher             = 'Werner Media inc.'
  15.     category              = 'news, music, USA, world'
  16.     oldest_article        = 15
  17.     max_articles_per_feed = 200
  18.     no_stylesheets        = True
  19.     encoding              = 'utf8'
  20.     use_embedded_content  = False
  21.     language              = 'en'
  22.     remove_empty_feeds    = True
  23.     publication_type      = 'magazine'
  24.     masthead_url          = 'http://www.rollingstone.com/templates/rolling-stone-templates/theme/rstheme/images/rsLogo.png'
  25.     extra_css             = """
  26.                                body{font-family: Georgia,Times,serif }
  27.                                img{margin-bottom: 0.4em; display:block}
  28.                             """
  29.  
  30.     conversion_options = {
  31.                           'comment'   : description
  32.                         , 'tags'      : category
  33.                         , 'publisher' : publisher
  34.                         , 'language'  : language
  35.                         }
  36.  
  37.     preprocess_regexps = [
  38.                           (re.compile(r'xml:lang="en">.*?<head>', re.DOTALL|re.IGNORECASE),lambda match: 'xml:lang="en">\n<head>\n')
  39.                          ,(re.compile(r'</title>.*?</head>'     , re.DOTALL|re.IGNORECASE),lambda match: '</title>\n</head>\n'     )
  40.                          ]
  41.  
  42.     keep_only_tags=[
  43.                      dict(attrs={'class':['headerImgHolder','headerContent']})
  44.                     ,dict(name='div',attrs={'id':['teaser','storyTextContainer']})
  45.                     ,dict(name='div',attrs={'class':'blogDetailModule clearfix'})
  46.                    ]
  47.  
  48.     remove_tags = [
  49.                       dict(name=['meta','iframe','object','embed'])
  50.                      ,dict(attrs={'id':'mpStoryHeader'})
  51.                      ,dict(attrs={'class':'relatedTopics'})
  52.                   ]
  53.     remove_attributes=['lang','onclick','width','height','name']
  54.     remove_tags_before=dict(attrs={'class':'bloggerInfo'})
  55.     remove_tags_after=dict(attrs={'class':'relatedTopics'})
  56.  
  57.  
  58.     feeds = [
  59.               (u'All News'      , u'http://www.rollingstone.com/siteServices/rss/allNews'      )
  60.              ,(u'All Blogs'     , u'http://www.rollingstone.com/siteServices/rss/allBlogs'     )
  61.              ,(u'Movie Reviews' , u'http://www.rollingstone.com/siteServices/rss/movieReviews' )
  62.              ,(u'Album Reviews' , u'http://www.rollingstone.com/siteServices/rss/albumReviews' )
  63.              ,(u'Song Reviews'  , u'http://www.rollingstone.com/siteServices/rss/songReviews'  )
  64.             ]
  65.  
  66.     def preprocess_html(self, soup):
  67.         for item in soup.findAll(style=True):
  68.             del item['style']
  69.         return soup
  70.