01-08-2009, 10:46 PM | #1 |
Member
Posts: 11
Karma: 18
Join Date: Jan 2009
Location: Minnesota
Device: PRS-505, iPhone 3GS, iPad
|
Run plugin before import
Is it possible for a plugin to run before the import is done? From tinkering around with a plugin it seems that the file is imported into the database and then the plugin runs.
I'd like to do some processing of a file before it is imported into Calibre. I would then like to have this processed file imported rather than the original file. Other random question, is there a variable that stores the install path to calibre? Thanks. |
01-08-2009, 10:52 PM | #2 |
creator of calibre
Posts: 44,515
Karma: 24495784
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
on_import = True causes the plugin to run just before the file is added to the database, but not before metadata is read from the file. If you want to change metadata reading, create a metadatareader plugin.
Getting the path to the calibre install directory is platform and installation method dependent. Here is some code to find the path to the plugins subdirectory ina calibre install Code:
if iswindows: plugin_path = os.path.join(os.path.dirname(sys.executable), 'plugins') sys.path.insert(1, os.path.dirname(sys.executable)) elif isosx: plugin_path = os.path.join(getattr(sys, 'frameworks_dir'), 'plugins') elif islinux: plugin_path = os.path.join(getattr(sys, 'frozen_path'), 'plugins') |
Advert | |
|
01-08-2009, 10:56 PM | #3 |
Member
Posts: 11
Karma: 18
Join Date: Jan 2009
Location: Minnesota
Device: PRS-505, iPhone 3GS, iPad
|
Thanks for the quick reply. The metadata I'm reading must be messed up. I never thought of trying a different file.
Drew |
01-08-2009, 11:58 PM | #4 | |
Grand Sorcerer
Posts: 19,832
Karma: 11844413
Join Date: Jan 2007
Location: Tampa, FL USA
Device: Kindle Touch
|
Quote:
BOb |
|
01-09-2009, 12:01 AM | #5 | |
creator of calibre
Posts: 44,515
Karma: 24495784
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
The problem is that the concept of "installation directory" is not well defined for a python program. Indeed, only the windows version could be said to have an "installation directory". Also plugins really shouldn't need to know where calibre is installed. |
|
Advert | |
|
01-09-2009, 01:39 PM | #6 |
Member
Posts: 11
Karma: 18
Join Date: Jan 2009
Location: Minnesota
Device: PRS-505, iPhone 3GS, iPad
|
Thanks for the help. I found my reason why the modifited file wasn't getting imported. I never updated the return statement to reflect the path of the updated file. Now it all seems to work, except the book name metadata isn't getting read correctly. All other fields seem correct except the book name.
Drew |
01-09-2009, 01:40 PM | #7 |
Grand Sorcerer
Posts: 19,832
Karma: 11844413
Join Date: Jan 2007
Location: Tampa, FL USA
Device: Kindle Touch
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 01:11 PM |
Referencer plugin | IanHelgesen | iRex | 6 | 12-22-2008 10:24 PM |
[Apple]Java Embedding Plugin 0.9.2: Force java to run in browsers other than Safari | Zire | Lounge | 4 | 05-24-2005 10:12 PM |