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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.uncrate.com
  7. '''
  8.  
  9. from calibre.web.feeds.recipes import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class Uncrate(BasicNewsRecipe):
  13.     title                  = 'Uncrate'
  14.     __author__             = 'Darko Miletic'
  15.     description            = 'Uncrate is a web magazine for guys who love stuff. Our team digs up the best gadgets, clothes, cars, DVDs and more. New items are posted daily. Enjoy responsively.'
  16.     oldest_article         = 7
  17.     max_articles_per_feed  = 100
  18.     no_stylesheets         = True
  19.     use_embedded_content   = False
  20.     encoding               = 'utf-8'
  21.     publisher              = 'Zombie corp.'
  22.     category               = 'news, gadgets, clothes, cars, DVDs'
  23.     lang                   = 'en-US'
  24.     language = 'en'
  25.  
  26.  
  27.     html2lrf_options = [
  28.                           '--comment', description
  29.                         , '--category', category
  30.                         , '--publisher', publisher
  31.                         ]
  32.  
  33.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
  34.  
  35.     keep_only_tags = [dict(name='div', attrs={'class':'lefttext'})]
  36.     remove_tags_after = dict(name='div', attrs={'class':'serif'})
  37.     remove_tags = [dict(name=['object','link','script','iframe','form'])]
  38.  
  39.     extra_css = '''
  40.                     .serif{font-family:Georgia,Rockwell,'Times New Roman',Times,serif; font-weight:normal; font-size: x-small; }
  41.                     .lefttext{font-family:Georgia,Rockwell,'Times New Roman',Times,serif; font-weight:normal; font-size: x-small; }  
  42.                     h1{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size:x-large; font-weight:bold;}
  43.                     .byline{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color:#FF4000;}
  44.                     .posted{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size: x-small;}
  45.                     .answer{ font-family:Verdana,Arial,Helvetica,sans-serif;font-size: x-small;}
  46.                     a{color:#FF4000;}
  47.                 '''
  48.      
  49.     feeds = [(u'Articles', u'http://feeds.feedburner.com/uncrate')]
  50.  
  51.     def preprocess_html(self, soup):
  52.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  53.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  54.         soup.head.insert(0,mlang)
  55.         soup.head.insert(1,mcharset)
  56.         for item in soup.findAll(style=True):
  57.             del item['style']
  58.         return self.adeify_images(soup)
  59.