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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. readitlaterlist.com
  5. '''
  6.  
  7. from calibre import strftime
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class Readitlater(BasicNewsRecipe):
  11.     title                 = 'Read It Later'
  12.     __author__            = 'Darko Miletic'
  13.     description           = '''Personalized news feeds. Go to readitlaterlist.com to
  14.                                setup up your news. Fill in your account
  15.                                username, and optionally you can add password.'''
  16.     publisher             = 'readitlater.com'
  17.     category              = 'news, custom'
  18.     oldest_article        = 7
  19.     max_articles_per_feed = 100
  20.     no_stylesheets        = True
  21.     use_embedded_content  = False
  22.     needs_subscription    = True
  23.     INDEX                 = u'http://readitlaterlist.com'
  24.     LOGIN                 = INDEX + u'/l'
  25.  
  26.  
  27.     feeds = [(u'Unread articles' , INDEX + u'/unread')]
  28.  
  29.     def get_browser(self):
  30.         br = BasicNewsRecipe.get_browser()
  31.         if self.username is not None:
  32.             br.open(self.LOGIN)
  33.             br.select_form(nr=0)
  34.             br['feed_id'] = self.username
  35.             if self.password is not None:
  36.                br['password'] = self.password
  37.             br.submit()
  38.         return br
  39.  
  40.     def parse_index(self):
  41.         totalfeeds = []
  42.         lfeeds = self.get_feeds()
  43.         for feedobj in lfeeds:
  44.             feedtitle, feedurl = feedobj
  45.             self.report_progress(0, _('Fetching feed')+' %s...'%(feedtitle if feedtitle else feedurl))
  46.             articles = []
  47.             soup = self.index_to_soup(feedurl)
  48.             ritem = soup.find('ul',attrs={'id':'list'})
  49.             for item in ritem.findAll('li'):
  50.                 description = ''
  51.                 atag = item.find('a',attrs={'class':'text'})
  52.                 if atag and atag.has_key('href'):
  53.                     url         = self.INDEX + atag['href']
  54.                     title       = self.tag_to_string(item.div)
  55.                     date        = strftime(self.timefmt)
  56.                     articles.append({
  57.                                       'title'      :title
  58.                                      ,'date'       :date
  59.                                      ,'url'        :url
  60.                                      ,'description':description
  61.                                     })
  62.             totalfeeds.append((feedtitle, articles))
  63.         return totalfeeds
  64.  
  65.