home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3745 < prev    next >
Encoding:
Text File  |  2009-10-14  |  2.3 KB  |  64 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5.  
  6. '''
  7. www.esquire.com
  8. '''
  9.  
  10. from calibre import strftime
  11. from calibre.web.feeds.news import BasicNewsRecipe
  12. from calibre.ebooks.BeautifulSoup import Tag
  13.  
  14. class Esquire(BasicNewsRecipe):
  15.     title                 = 'Esquire'
  16.     __author__            = 'Darko Miletic'
  17.     description           = 'Esquire: Man at His Best'
  18.     publisher             = 'Hearst Communications, Inc.'
  19.     category              = 'magazine, men, women we love, style, the guide, sex, screen'
  20.     oldest_article        = 30
  21.     max_articles_per_feed = 100
  22.     no_stylesheets        = True
  23.     encoding              = 'cp1250'
  24.     use_embedded_content  = False
  25.     language = 'en'
  26.  
  27.     lang                  = 'en-US'
  28.     cover_url             = strftime('http://www.esquire.com/cm/esquire/cover-images/%Y_') + strftime('%m').strip('0') + '.jpg'
  29.  
  30.     conversion_options = {
  31.                           'comment'          : description
  32.                         , 'tags'             : category
  33.                         , 'publisher'        : publisher
  34.                         , 'language'         : lang
  35.                         , 'pretty_print'     : True
  36.                         }
  37.  
  38.     keep_only_tags = [dict(name='div', attrs={'id':'content'})]
  39.  
  40.     remove_tags = [dict(name=['object','link','embed','iframe'])]
  41.  
  42.     feeds = [
  43.                (u'Style'    , u'http://www.esquire.com/style/rss/'    )
  44.               ,(u'Women'    , u'http://www.esquire.com/women/rss/'    )
  45.               ,(u'Features' , u'http://www.esquire.com/features/rss/' )
  46.               ,(u'Fiction'  , u'http://www.esquire.com/fiction/rss/'  )
  47.               ,(u'Frontpage', u'http://www.esquire.com/rss/'          )
  48.             ]
  49.  
  50.  
  51.     def print_version(self, url):
  52.         rest = url.rpartition('?')[0]
  53.         article = rest.rpartition('/')[2]
  54.         return 'http://www.esquire.com/print-this/' + article
  55.  
  56.     def preprocess_html(self, soup):
  57.         soup.html['xml:lang'] = self.lang
  58.         soup.html['lang']     = self.lang
  59.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  60.         soup.head.insert(0,mlang)
  61.         for item in soup.findAll(style=True):
  62.             del item['style']
  63.         return soup
  64.