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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2008 - 2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. thenation.com
  5. '''
  6. from calibre.web.feeds.news import BasicNewsRecipe
  7.  
  8. class Thenation(BasicNewsRecipe):
  9.     title                 = 'The Nation'
  10.     __author__            = 'Darko Miletic'
  11.     description           = 'Unconventional Wisdom Since 1865'
  12.     publisher             = 'The Nation'
  13.     category              = 'news, politics, USA'
  14.     oldest_article        = 120
  15.     encoding              = 'utf-8'
  16.     max_articles_per_feed = 100
  17.     no_stylesheets        = True
  18.     language              = 'en'
  19.     use_embedded_content  = False
  20.     delay                 = 1
  21.     masthead_url          = 'http://www.thenation.com/sites/default/themes/thenation/images/logo-main.gif'
  22.     login_url             = 'http://www.thenation.com/user?destination=%3Cfront%3E'
  23.     publication_type      = 'magazine'
  24.     needs_subscription    = 'optional'    
  25.     exra_css              = """ 
  26.                               body{font-family: Arial,Helvetica,sans-serif;} 
  27.                               .print-created{font-size: small;} 
  28.                               .caption{display: block; font-size: x-small;}
  29.                             """
  30.  
  31.     conversion_options = {
  32.                           'comment'   : description
  33.                         , 'tags'      : category
  34.                         , 'publisher' : publisher
  35.                         , 'language'  : language
  36.                         }
  37.  
  38.     keep_only_tags    = [dict(attrs={'class':['print-title','print-created','print-content','print-links']})]
  39.     remove_tags       = [dict(name=['link','iframe','base','meta','object','embed'])]
  40.     remove_attributes = ['lang']
  41.  
  42.     feeds       = [(u"Articles", u'http://www.thenation.com/rss/articles')]
  43.  
  44.     def print_version(self, url):
  45.         return url.replace('.thenation.com/','.thenation.com/print/')
  46.  
  47.     def get_browser(self):
  48.         br = BasicNewsRecipe.get_browser()
  49.         br.open('http://www.thenation.com/')
  50.         if self.username is not None and self.password is not None:
  51.             br.open(self.login_url)
  52.             br.select_form(nr=1)
  53.             br['name'] = self.username
  54.             br['pass'] = self.password
  55.             br.submit()
  56.         return br
  57.  
  58.     def get_cover_url(self):
  59.         soup = self.index_to_soup('http://www.thenation.com/issue/')
  60.         item = soup.find('div',attrs={'id':'cover-wrapper'})
  61.         if item:           
  62.            return item.img['src']
  63.         return None
  64.