Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-05-2010, 06:22 PM   #1
oecherprinte
Zealot
oecherprinte began at the beginning.
 
Posts: 114
Karma: 20
Join Date: Jul 2010
Device: Kindle3 3G, Kindle Paperwhite 2
Passing parameters to recipe from "Schedule News Download" Window (e.g. for filtering

Hi,

I would love to pass some parameters (filter options) to a custom
recipe from the "Schedule News Download" Window. I do not
want to have to edit the recipe every time I would like to change
my article filtering options.

Are you aware of any possibilities for doing that? There are the undocumented Advanced Features like "Extra Tags". Can I do anything with that?

Then of course I could program a popup gui window in python to select the parameters directy in the running recipe. But that would involve quite some programming.

Thanks,

Jens
oecherprinte is offline   Reply With Quote
Old 11-05-2010, 09:44 PM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by oecherprinte View Post
I would love to pass some parameters (filter options) to a custom
recipe from the "Schedule News Download" Window. I do not
want to have to edit the recipe every time I would like to change
my article filtering options.
Many others have wanted to do this.
Quote:
Are you aware of any possibilities for doing that?
Yes, but limited, and you won't like it much.
Quote:
There are the undocumented Advanced Features like "Extra Tags". Can I do anything with that?
No.

Pass in via the username password, or a file that your recipe reads are options.
Starson17 is offline   Reply With Quote
Old 11-06-2010, 04:36 PM   #3
oecherprinte
Zealot
oecherprinte began at the beginning.
 
Posts: 114
Karma: 20
Join Date: Jul 2010
Device: Kindle3 3G, Kindle Paperwhite 2
I have come up with a solution that I find quite elegant:

I just open up dialog popups to poll the parameter from the recipe itself. This is how I did it:

1. Add the following lines to the top of the recipe to load pyqt4 (the qt implementation for python)

Code:
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
2. Open a dialog window in the recipe wherever you need to poll a parameter. I placed it in the "parse_index" function to poll the number of feeds that should be processed. Just place the following code wherever you need it. I am polling an integer value, but getting a text is equally easy (I commented out the corresponding line).

Code:
    
            #####################
	    # dialog to get parameters
	    #####################
    
    
            #create gui application for dialog (I think you do not need it it's a leftover)	    
	    app = QtGui.QApplication(sys.argv)

	    #get widget
	    widget = QtGui.QWidget()
	    
	    
	    #open dialog to input integer variables
	    tmp_no_feeds, ok=QtGui.QInputDialog.getInteger(widget, 'Input Dialog - Number of Feeds', 'Number of feeds:',8)
	    
	    #this would be the text input dialog
	    #no_feeds, ok=QtGui.QInputDialog.getText(widget, 'Input Dialog - Text example', 'Enter text:',QtGui.QLineEdit.Normal,'default text')

	    
	    #take value if ok was pressed otherwise use default value
	    if ok:
	     no_feeds=tmp_no_feeds
	    else:
	    #default
	     no_feeds=8
	    
	    #you may now use the variable no_feeds
	    self.log('\t\tno_feeds=',no_feeds) 
	     
	    ###########################
	    # end dialog
	    ###########################
An in depth description of the pyqt4 library can be found here:

http://zetcode.com/tutorials/pyqt4/

I used a procedural style to open the dialogs since I find it simpler to integrate into a recipe.

Hope this helps some people having the same problems.

Cheers,

Jens

P.S.: This approach is of course problematic if you would like to automatically schedule your recipes in the middle of the night since it will not run if you do not respond to the dialog boxes ...

Last edited by oecherprinte; 11-06-2010 at 05:00 PM.
oecherprinte is offline   Reply With Quote
Old 05-13-2011, 12:55 AM   #4
cod2
Junior Member
cod2 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
Thanks, Jens! Just what I was looking for!
cod2 is offline   Reply With Quote
Old 05-13-2011, 10:12 AM   #5
cod2
Junior Member
cod2 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
I'm setting recipe_disabled to a non empty string to abort the recipe when user click on cancel button. The recipe stops with a error dialog window.

Is there any other way to cancel a recipe?
cod2 is offline   Reply With Quote
Old 05-13-2011, 10:17 AM   #6
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by cod2 View Post
Thanks, Jens! Just what I was looking for!
I presume you don't use this function for scheduled recipes.
Starson17 is offline   Reply With Quote
Old 05-13-2011, 11:38 AM   #7
cod2
Junior Member
cod2 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2010
Device: Kindle 3
Quote:
Originally Posted by Starson17 View Post
I presume you don't use this function for scheduled recipes.
No, I'm using to download back issues of Brazilian magazine Piauí (great magazine if you read Portuguese)... they provide full version of back issues on their site. The dialog window is used to ask which issue to download.

I'm writing a scheduled version too, without the dialog window, to be used in monthly basis to download the last full back issue available.
cod2 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre recipe for daily Portuguese newspaper "Correio da Manhã" jmst Recipes 2 11-01-2010 01:01 PM
"Fetch News" download time? oilcan Calibre 1 09-26-2010 01:29 PM
Schedule news, but manual download MightyMauz Calibre 3 09-04-2010 07:54 AM
Call "print newspapers" as "snailpapers" because they arrive with news is 12 hrs old taglines Lounge 4 02-05-2010 10:01 AM
Schedule news download AprilHare Calibre 31 02-11-2009 04:20 AM


All times are GMT -4. The time now is 11:04 PM.


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