|
|
#1 |
|
Member
![]() Posts: 11
Karma: 18
Join Date: Jan 2009
Location: Minnesota
Device: PRS-505, iPhone 3GS, iPad
|
Run plugin before import
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. |
|
|
|
|
|
#2 |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,489
Karma: 2944574
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')
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
Enthusiast
|
|
|
|
#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 |
|
|
|
|
|
#4 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 18,753
Karma: 4233896
Join Date: Jan 2007
Location: Tampa, FL USA
Device: Kindle Touch
|
Quote:
BOb
__________________
Never ascribe to malice that which is adequately explained by incompetence. --Napoleon Bonaparte |
|
|
|
|
|
|
#5 | |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,489
Karma: 2944574
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.
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
|
|
#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 |
|
|
|
|
|
#7 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 18,753
Karma: 4233896
Join Date: Jan 2007
Location: Tampa, FL USA
Device: Kindle Touch
|
Quote:
BOb
__________________
Never ascribe to malice that which is adequately explained by incompetence. --Napoleon Bonaparte |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 12:11 PM |
| Referencer plugin | IanHelgesen | iRex | 6 | 12-22-2008 09:24 PM |
| [Apple]Java Embedding Plugin 0.9.2: Force java to run in browsers other than Safari | Zire | Lounge | 4 | 05-24-2005 09:12 PM |