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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.adventuregamers.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class AdventureGamers(BasicNewsRecipe):
  10.     title                 = u'Adventure Gamers'
  11.     language              = 'en'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Adventure games portal'
  14.     publisher             = 'Adventure Gamers'
  15.     category              = 'news, games, adventure, technology'
  16.     oldest_article        = 10
  17.     delay                 = 10
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     encoding              = 'cp1252'
  21.     remove_javascript     = True
  22.     use_embedded_content  = False
  23.     INDEX                 = u'http://www.adventuregamers.com'
  24.     extra_css             = """
  25.                                 .pageheader_type{font-size: x-large; font-weight: bold; color: #828D74}
  26.                                 .pageheader_title{font-size: xx-large; color: #394128}
  27.                                 .pageheader_byline{font-size: small; font-weight: bold; color: #394128}
  28.                                 .score_bg {display: inline; width: 100%; margin-bottom: 2em}
  29.                                 .score_column_1{ padding-left: 10px; font-size: small; width: 50%}
  30.                                 .score_column_2{ padding-left: 10px; font-size: small; width: 50%}
  31.                                 .score_column_3{ padding-left: 10px; font-size: small; width: 50%}
  32.                                 .score_header{font-size: large; color: #50544A}
  33.                                 .bodytext{display: block}
  34.                                 body{font-family: Helvetica,Arial,sans-serif}
  35.                             """
  36.  
  37.     conversion_options = {
  38.                           'comment'   : description
  39.                         , 'tags'      : category
  40.                         , 'publisher' : publisher
  41.                         , 'language'  : language
  42.                         }
  43.  
  44.     keep_only_tags = [
  45.                        dict(name='div', attrs={'class':'content_middle'})
  46.                      ]
  47.  
  48.     remove_tags = [
  49.                      dict(name=['object','link','embed','form'])
  50.                     ,dict(name='div', attrs={'class':['related-stories','article_leadout','prev','next','both']})
  51.                   ]
  52.  
  53.     remove_tags_after = [dict(name='div', attrs={'class':'toolbar_fat'})]
  54.     remove_attributes = ['width','height']
  55.  
  56.     feeds = [(u'Articles', u'http://feeds2.feedburner.com/AdventureGamers')]
  57.  
  58.     def get_article_url(self, article):
  59.         return article.get('guid',  None)
  60.  
  61.     def append_page(self, soup, appendtag, position):
  62.         pager = soup.find('div',attrs={'class':'toolbar_fat_next'})
  63.         if pager:
  64.            nexturl = self.INDEX + pager.a['href']
  65.            soup2 = self.index_to_soup(nexturl)
  66.            texttag = soup2.find('div', attrs={'class':'bodytext'})
  67.            for it in texttag.findAll(style=True):
  68.                del it['style']
  69.            newpos = len(texttag.contents)
  70.            self.append_page(soup2,texttag,newpos)
  71.            texttag.extract()
  72.            appendtag.insert(position,texttag)
  73.  
  74.  
  75.     def preprocess_html(self, soup):
  76.         for item in soup.findAll(style=True):
  77.             del item['style']
  78.         for item in soup.findAll('div', attrs={'class':'floatright'}):
  79.             item.extract()
  80.         self.append_page(soup, soup.body, 3)
  81.         pager = soup.find('div',attrs={'class':'toolbar_fat'})
  82.         if pager:
  83.            pager.extract()
  84.         return self.adeify_images(soup)
  85.