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 10-21-2014, 06:11 AM   #1
sakib
Nameless Being
 
Question Is it possible to provide external URL for recipe processing?

Hi folks,
I've been trying to convert a bunch of articles from online journal (namely LWN.net). Yet recipe only fetches current issue if you're member, or previous one if you're not. I couldn't find a way to provide a specific article URL to fetch & process in API documentation neither to ebook-convert utility nor to BasicNewsRecipe class (I wanted to convert some of old issues).

So question is: are there any ways to use news recipe for specific article or issue, which URL can be passed as parameters for ebook-convert or some other way for recipe methods?

Thank you!
  Reply With Quote
Old 10-21-2014, 06:29 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,168
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Simply implement parse_index in your custom recipe class, it can return any set of urls you like. See the recipe api documentation for examples.
kovidgoyal is online now   Reply With Quote
Advert
Old 10-21-2014, 08:04 AM   #3
sakib
Nameless Being
 
Quote:
Originally Posted by kovidgoyal View Post
Simply implement parse_index in your custom recipe class, it can return any set of urls you like. See the recipe api documentation for examples.
I'm doing the similar way, only take actual article URL from shell environment variable and invoke ebook-convert in loop each time with next article from list. What I was actually interested in is more clean & generic way to deal with arbitrary URLs, but it seems that recipes API lacks this kind of feature
  Reply With Quote
Old 10-21-2014, 12:11 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,168
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Whydont you simply have your shell script generate a custom recipe, filling in the feed URLs from the environment/stdin/whatever. You can put all URLS into one custom recipe.
kovidgoyal is online now   Reply With Quote
Old 10-22-2014, 11:58 AM   #5
sakib
Nameless Being
 
what I did is mangle original recipe a bit:
Code:
diff --git a/recipes/lwn_weekly.recipe b/recipes/lwn_weekly.recipe
index 6392772..b4055ef 100644
--- a/recipes/lwn_weekly.recipe
+++ b/recipes/lwn_weekly.recipe
@@ -9,6 +9,7 @@
 from calibre.web.feeds.news import BasicNewsRecipe
 import re
 import sys
+import os
 
 class WeeklyLWN(BasicNewsRecipe):
     title = 'LWN.net Weekly Edition'
@@ -72,7 +73,9 @@ def parse_index(self):
         if self.username is not None and self.password is not None:
             index_url = self.print_version('/current/bigpage')
         else:
-            index_url = self.print_version('/free/bigpage')
+            issue = os.environ.get('OVERRIDE_LWN_ISSUE')
+            index_url = self.print_version("/Articles/%s/bigpage" % issue)
+            print >>sys.stderr, "overriden issue %s" % index_url
         soup = self.index_to_soup(index_url)
         curr = soup.body
         if curr.h1.string is not None:
and use it together with small shell script, plus list of issues grabbed from my RSS reader:
Code:
#!/bin/bash
counter=0
for OVERRIDE_LWN_ISSUE in 515278 514343 510440...; do
	if [ -f ./out/lwn_$counter.epub ]; then
		((counter++));
		continue
	fi
	echo process $OVERRIDE_LWN_ISSUE $counter;
	export OVERRIDE_LWN_ISSUE
	ebook-convert ./lwn_weekly.recipe ./out/lwn_$counter.epub ;
	if [ $? != 0 ]; then
		echo "processing issue $OVERRIDE_LWN_ISSUE $counter failed"
		exit
	fi
	((counter++));
done
Converted this way all issues for last 2 years.
Not sure that somebody needs this, but I just leave it here anyway.
  Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NME recipe URL correction scissors Recipes 0 05-17-2013 10:41 AM
recipe problem with space in cover url forceps Development 4 08-27-2012 04:32 PM
PRS-T1 VNC viewer for word processing + external keyboard? multiprose Sony Reader Dev Corner 4 04-24-2012 05:30 PM
Lists getting changed in recipe processing ptsefton Recipes 2 05-18-2011 10:40 PM
Simple download from rss url recipe BloodOmen Recipes 0 02-16-2011 09:21 PM


All times are GMT -4. The time now is 07:54 PM.


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