Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 07-04-2011, 07:51 AM   #31
khromov
Connoisseur
khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.
 
Posts: 83
Karma: 499304
Join Date: Jul 2011
Device: Kindle
I did make some small improvements to Dereks code above.

Changes:
- Removed "Loved/Starred" category (Because it fills up over time)
- Remove the "<< Back to Instapaper" text at the end of every article.

Code:
import urllib
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe

class AdvancedUserRecipe1299694372(BasicNewsRecipe):
    title                             = u'Instapaper'
    __author__                  = 'Darko Miletic'
    publisher                     = 'Instapaper.com'
    category                      = 'info, custom, Instapaper'
    oldest_article               = 365
    max_articles_per_feed = 100
    no_stylesheets        = True
    remove_javascript     = True
    remove_tags              = [
	dict(name='div', attrs={'id':'text_controls_toggle'})
	,dict(name='script')
	,dict(name='div', attrs={'id':'text_controls'})
	,dict(name='div', attrs={'id':'editing_controls'})
	,dict(name='div', attrs={'class':'bar bottom'})
	 ]
    use_embedded_content  = False
    needs_subscription    = True
    INDEX                 = u'http://www.instapaper.com'
    LOGIN                 = INDEX + u'/user/login'


    feeds          = [(u'Instapaper Unread', u'http://www.instapaper.com/u')]

    def get_browser(self):
        br = BasicNewsRecipe.get_browser()
        if self.username is not None:
            br.open(self.LOGIN)
            br.select_form(nr=0)
            br['username'] = self.username
            if self.password is not None:
               br['password'] = self.password
            br.submit()
        return br

    def parse_index(self):
        totalfeeds = []
        lfeeds = self.get_feeds()
        for feedobj in lfeeds:
            feedtitle, feedurl = feedobj
            self.report_progress(0, _('Fetching feed')+' %s...'%(feedtitle if feedtitle else feedurl))
            articles = []
            soup = self.index_to_soup(feedurl)
            for item in soup.findAll('div', attrs={'class':'cornerControls'}):
                description = self.tag_to_string(item.div)
                atag = item.a
                if atag and atag.has_key('href'):
                    url         = atag['href']
                    articles.append({
                                     'url'        :url
                                    })
            totalfeeds.append((feedtitle, articles))
        return totalfeeds

    def print_version(self, url): 
        return 'http://www.instapaper.com' + url

    def populate_article_metadata(self, article, soup, first):
        article.title  = soup.find('h1').contents[0].strip()
khromov is offline   Reply With Quote
Old 07-08-2011, 06:18 AM   #32
Dereks
Connoisseur
Dereks began at the beginning.
 
Posts: 57
Karma: 10
Join Date: Feb 2010
Device: Kindle Paperwhite 1
Yes, if you are using your own folders in instapapers, they won't show up in this recipe. But you can add them easily in the same way, as "Loved Articles" was added.

Just find this line in the recipe:

Code:
    feeds          = [(u'Instapaper Unread', u'http://www.instapaper.com/u')]
and then add something like this inside the square brackets:

Code:
(u'Folder Name', u'http://www.instapaper.com/u/folder/numericalidentificator/folder name')
you can find the exact link by simply hovering over the folder in instapaper sidebar. Just copy it and insert as explain above and articles from this folder will appear in instapaper recipe feed as a separate section.
Also, note that the numerical indentificator in the url between /folder/ and /folder name is always unique for each folder - it's not linked to users account or anything, be sure to copy-paste it all correctly.
Dereks is offline   Reply With Quote
Old 07-18-2011, 03:01 PM   #33
khromov
Connoisseur
khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.
 
Posts: 83
Karma: 499304
Join Date: Jul 2011
Device: Kindle
Another update incoming. I noticed that the text-only view on some articles did not have a <h1> tag for me to reflect the title, so I changed the script to use the <title> tag instead, which always reflects the article title.

The code in its entirety can be found below: (Remember to use Dereks post above if you want to add your Archive and other custom folders.)

Code:
import urllib
from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe

class AdvancedUserRecipe1299694372(BasicNewsRecipe):
    title                             = u'Instapaper'
    __author__                  = 'Darko Miletic'
    publisher                     = 'Instapaper.com'
    category                      = 'info, custom, Instapaper'
    oldest_article               = 365
    max_articles_per_feed = 100
    no_stylesheets        = True
    remove_javascript     = True
    remove_tags              = [
	dict(name='div', attrs={'id':'text_controls_toggle'})
	,dict(name='script')
	,dict(name='div', attrs={'id':'text_controls'})
	,dict(name='div', attrs={'id':'editing_controls'})
	,dict(name='div', attrs={'class':'bar bottom'})
	 ]
    use_embedded_content  = False
    needs_subscription    = True
    INDEX                 = u'http://www.instapaper.com'
    LOGIN                 = INDEX + u'/user/login'


    feeds          = [(u'Instapaper Unread', u'http://www.instapaper.com/u')]

    def get_browser(self):
        br = BasicNewsRecipe.get_browser()
        if self.username is not None:
            br.open(self.LOGIN)
            br.select_form(nr=0)
            br['username'] = self.username
            if self.password is not None:
               br['password'] = self.password
            br.submit()
        return br

    def parse_index(self):
        totalfeeds = []
        lfeeds = self.get_feeds()
        for feedobj in lfeeds:
            feedtitle, feedurl = feedobj
            self.report_progress(0, _('Fetching feed')+' %s...'%(feedtitle if feedtitle else feedurl))
            articles = []
            soup = self.index_to_soup(feedurl)
            for item in soup.findAll('div', attrs={'class':'cornerControls'}):
                description = self.tag_to_string(item.div)
                atag = item.a
                if atag and atag.has_key('href'):
                    url         = atag['href']
                    articles.append({
                                     'url'        :url
                                    })
            totalfeeds.append((feedtitle, articles))
        return totalfeeds

    def print_version(self, url): 
        return 'http://www.instapaper.com' + url

    def populate_article_metadata(self, article, soup, first):
        article.title  = soup.find('title').contents[0].strip()
khromov is offline   Reply With Quote
Old 08-01-2011, 02:23 PM   #34
brendanl79
Member
brendanl79 began at the beginning.
 
Posts: 18
Karma: 14
Join Date: Jan 2009
Location: Massachusetts, USA
Device: Kindle Voyage x2, Onyx BOOX Note 3
Unhappy

I have a couple dozen unread articles on my Instapaper account but my fetch yields only an empty EPUB (cover page and Instapaper TOC are there, but no articles).

Calibre 0.8.12 on Fedora 14-x64. :-(
UPDATE: same result with Calibre 0.8.12 on Win7-x64.

I'm not too familiar with Python - any hints as to how I might begin to diagnose this?

Last edited by brendanl79; 08-01-2011 at 03:24 PM.
brendanl79 is offline   Reply With Quote
Old 08-02-2011, 08:03 AM   #35
khromov
Connoisseur
khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.khromov ought to be getting tired of karma fortunes by now.
 
Posts: 83
Karma: 499304
Join Date: Jul 2011
Device: Kindle
Quote:
Originally Posted by brendanl79 View Post
I have a couple dozen unread articles on my Instapaper account but my fetch yields only an empty EPUB (cover page and Instapaper TOC are there, but no articles).

Calibre 0.8.12 on Fedora 14-x64. :-(
UPDATE: same result with Calibre 0.8.12 on Win7-x64.

I'm not too familiar with Python - any hints as to how I might begin to diagnose this?
I assume you are using the built-in Instapaper recipe in Calibre 0.8.12. That recipe has a thread here:
https://www.mobileread.com/forums/sho...d.php?t=143343

The easiest way to diagnose this would be if you sent me the log file to a failed run of your recipe via PM. (Don't post the log on the forum as it contains your Instapaper password, or remove the password before posting the log.)
khromov is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre + Instapaper Limits feelsgoodman Calibre 3 11-27-2010 02:40 AM
Syncing your Instapaper articles to your Kindle Jeton Amazon Kindle 0 10-08-2010 03:28 AM
Instapaper folders and Calibre flyash Calibre 4 08-13-2010 02:01 AM
Calibre, Instapaper, multipage articles and ordering flyash Calibre 1 06-10-2010 07:03 PM
Want best reader for downloading magazine articles, almost bought jetBook for $179 brettmiller Which one should I buy? 7 01-10-2009 03:01 PM


All times are GMT -4. The time now is 07:53 AM.


MobileRead.com is a privately owned, operated and funded community.