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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. gamasutra.com
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class Gamasutra(BasicNewsRecipe):
  11.     title                 = 'Gamasutra Featured articles'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'The Art and Business of Making Games'
  14.     publisher             = 'Gamasutra'
  15.     category              = 'news, games, IT'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 200
  18.     no_stylesheets        = True
  19.     encoding              = 'cp1252'
  20.     use_embedded_content  = False
  21.     language              = 'en'
  22.     remove_empty_feeds    = True
  23.     masthead_url          = 'http://www.gamasutra.com/images/gamasutra_logo.gif'
  24.     extra_css             = ' body{font-family: Verdana,Arial,Helvetica,sans-serif } img{margin-bottom: 0.4em} .title{font-size: x-large; font-weight: bold} '
  25.  
  26.     conversion_options = {
  27.                           'comment'          : description
  28.                         , 'tags'             : category
  29.                         , 'publisher'        : publisher
  30.                         , 'language'         : language
  31.                         , 'linearize_tables' : True
  32.                         }
  33.     preprocess_regexps = [
  34.                            (re.compile(r'<head>.*?<title>', re.DOTALL|re.IGNORECASE),lambda match: '<head><title>')
  35.                           ,(re.compile(r'</title>.*?</head>', re.DOTALL|re.IGNORECASE),lambda match: '</title></head>')
  36.                           ,(re.compile(r'</head>', re.DOTALL|re.IGNORECASE),lambda match: '</head><body>')
  37.                          ]
  38.     remove_tags       = [
  39.                           dict(name=['object','embed','iframe'])
  40.                          ,dict(attrs={'class':'adBox'})
  41.                          ]
  42.     remove_tags_before = dict(attrs={'class':'title'})
  43.     remove_attributes = ['width','height','name']
  44.  
  45.     feeds = [(u'Feature Articles', u'http://feeds.feedburner.com/GamasutraFeatureArticles')]
  46.  
  47.     def print_version(self, url):
  48.         return url + '?print=1'
  49.  
  50.     def get_article_url(self, article):
  51.         return article.get('guid',  None)
  52.  
  53.     def preprocess_html(self, soup):
  54.         for item in soup.findAll(style=True):
  55.             del item['style']
  56.         return self.adeify_images(soup)
  57.