Instapaper updated

This commit is contained in:
Kovid Goyal 2012-06-02 09:24:09 +05:30
parent f6f6d5236e
commit 1122e26a00

View File

@ -1,9 +1,13 @@
#v2 2011-07-25 # Calibre recipe for Instapaper.com (Stable version)
#
# Homepage: http://khromov.wordpress.com/projects/instapaper-calibre-recipe/
# Code Repository: https://bitbucket.org/khromov/calibre-instapaper
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1299694372(BasicNewsRecipe): class AdvancedUserRecipe1299694372(BasicNewsRecipe):
title = u'Instapaper' title = u'Instapaper'
__author__ = 'Darko Miletic, Stanislav Khromov' __author__ = 'Darko Miletic, Stanislav Khromov, Jim Ramsay'
publisher = 'Instapaper.com' publisher = 'Instapaper.com'
category = 'info, custom, Instapaper' category = 'info, custom, Instapaper'
oldest_article = 365 oldest_article = 365
@ -24,12 +28,14 @@ class AdvancedUserRecipe1299694372(BasicNewsRecipe):
INDEX = u'http://www.instapaper.com' INDEX = u'http://www.instapaper.com'
LOGIN = INDEX + u'/user/login' LOGIN = INDEX + u'/user/login'
feeds = [ feeds = [
(u'Instapaper Unread', u'http://www.instapaper.com/u'), (u'Instapaper Unread', u'http://www.instapaper.com/u')
(u'Instapaper Starred', u'http://www.instapaper.com/starred') (u'Instapaper Starred', u'http://www.instapaper.com/starred')
] ]
#Adds the title tag to the body of the recipe. Use this if your articles miss headings.
add_title_tag = False;
def get_browser(self): def get_browser(self):
br = BasicNewsRecipe.get_browser() br = BasicNewsRecipe.get_browser()
if self.username is not None: if self.username is not None:
@ -67,7 +73,10 @@ class AdvancedUserRecipe1299694372(BasicNewsRecipe):
article.title = soup.find('title').contents[0].strip() article.title = soup.find('title').contents[0].strip()
def postprocess_html(self, soup, first_fetch): def postprocess_html(self, soup, first_fetch):
#adds the title to each story, as it is not always included
if self.add_title_tag:
for link_tag in soup.findAll(attrs={"id" : "story"}): for link_tag in soup.findAll(attrs={"id" : "story"}):
link_tag.insert(0,'<h1>'+soup.find('title').contents[0].strip()+'</h1>') link_tag.insert(0,'<h1>'+soup.find('title').contents[0].strip()+'</h1>')
#print repr(soup)
return soup return soup