Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 05-02-2015, 03:59 AM   #256
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@BR: But that's the problem. The Search The Internet plugin is designed to build a search URL and get that handled. The Open With plugin is designed to pass a books path to an executable with some options. Neither does what Vortex wants.

My thought was to change the Open With plugin to have an option that parses templates like the Search the Internet plugin and optionally includes the file path. After a quick look at both plugins, I think the hardest part of doing this is making sure the existing function didn't break. Well, the template parsing might be a bit harder, but hopefully calibre has some helpers to ease the pain.

My other suggestion was a wrapper script. It could be put into the Search The Internet plugin in the same way you suggested for the everything search executable. The script would convert the search parameters from URL style to those needed for the search program and then call it.
davidfor is offline   Reply With Quote
Old 05-02-2015, 05:12 AM   #257
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Putting my money were my mouth is...

Attached is version of the Open With plugin that I think does what Vortex want. The visible changes are in the configuration dialog.

In the "Format" column, I have added the type "TEMPLATE". When this is selected, the text entered in the "Args" column is treated as a template. When you select a book and Open With the template item, the text in the args column is evaluated as a template. This is then passed to the application being opened as the parameters. The file name of a book format is not used.

So for Vortex, you should create an Open With item with:

- Title: Everything Search
- Format: TEMPLATE
- Application: C:\Program Files\Everything\Everything.exe
- Args: -search {authors} {title}

With that, it should pass the authors and the title of the book as the search string. I don't use Everything Search, so I don't know the exact parameters.

This is a quick and dirty change. There is no validation or error checking. If it is close to what is needed, and works for others, I will finish it up.
Attached Files
File Type: zip Open With-Beta.zip (104.8 KB, 297 views)
davidfor is offline   Reply With Quote
Advert
Old 05-02-2015, 06:03 AM   #258
Vortex
Groupie
Vortex began at the beginning.
 
Vortex's Avatar
 
Posts: 171
Karma: 10
Join Date: Dec 2008
Device: Likebook Mars
Thanks for trying that out, David.

Using the exact settings as above, I get the 'Everything' error message:

Unable to open file list: C:\Users\-\Desktop\-search <Authors Name> <Book Title> is not a valid file list.

Which is odd as neither the book nor 'Everything' are located on the desktop.

If I remove all the Args so the box is empty, it then opens an empty Everything search box.

Quote:
Originally Posted by BetterRed View Post
@Vortex - what happens if you wrap the author in double quotes ie - file:///c:\program files\everything\everything.exe {"author"}
BR
The (Search the Internet) plugin cant seem to handle any filename with spaces, so as it is above it does nothing. If I change the file location to one with no spaces and remove the Args after the .exe then it will open 'Everything' with no search term passed. Putting anything after the .exe stops even that from working.

Using the webrun: protocol ( http://www.webrunapps.com/ ), which is the same idea as the AHK solution that Chaley suggested:

webrun:C:\Everything\Everything.exe -s {title}

That opens everything with the search term passed but with + symbols between every term. If I put title (and/or author) into double quotes it gives the error "not a valid file list"

My next idea was to use some kind of intermediary like a batch file to send the search term to, clean out the + symbols and then pass it on to 'Everything'.

Last edited by Vortex; 05-02-2015 at 06:09 AM.
Vortex is offline   Reply With Quote
Old 05-02-2015, 06:12 AM   #259
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by davidfor View Post
* chaley: stop rolling your eyes at my glib statement
I am glad I didn't do any eye rolling.

Quote:
Originally Posted by davidfor View Post
Putting my money were my mouth is...
...
Is there a reason that you didn't simply allow templates in the args column for all the formats? This would work easily unless people are using paired { } characters in their arguments, because the template processor passes through anything that isn't a template language expression. If use of braces is a concern (I have no idea) then you could use a prefix to indicate that the argument string is to be passed through the template processor after stripping off the prefix, perhaps something like {TEMPLATE} or ::TEMPLATE::.

Another thought: my guess is that the path to the file is tacked onto the end of the command after the arguments. I can easily imagine cases where that isn't what one wants. If one can use the template processor in any argument list then the user can put the filename wherever it is needed. The trick is to put the path where the template processor can find it. I suggest that sticking it into an "odd" identifier is the best way to go. Something like the following:
Code:
def init_cache(library_path):
	from calibre.db.backend import DB
	from calibre.db.cache import Cache
	backend = DB(library_path)
	cache = Cache(backend)
	cache.init()
	return cache

from calibre.ebooks.metadata.book.formatter import SafeFormat
	
cache = init_cache(library_path = sys.argv[1])
formatter = SafeFormat()

# Loop through all the books in the library
for id_ in cache.all_book_ids():
	mi = cache.get_metadata(id_)
	mi.set_identifier("**filepath", cache.format_abspath(id_, "epub"))
	print(formatter.safe_format("{title} {tags} {identifiers:select(**filepath)}", mi, _('TEMPLATE ERROR'), mi ))
Using this idea would require you to know that the argument template is taking care of paths so you don't stick it at the end. Perhaps a second prefix is the best way to go, something like "{PATHTEMPLATE}". If you do this then you would not need the "TEMPLATE" type because the user would have control over if and where the path string is put.
chaley is offline   Reply With Quote
Old 05-02-2015, 07:13 AM   #260
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by chaley View Post
I am glad I didn't do any eye rolling.

Is there a reason that you didn't simply allow templates in the args column for all the formats? This would work easily unless people are using paired { } characters in their arguments, because the template processor passes through anything that isn't a template language expression. If use of braces is a concern (I have no idea) then you could use a prefix to indicate that the argument string is to be passed through the template processor after stripping off the prefix, perhaps something like {TEMPLATE} or ::TEMPLATE::.
I think I said "quick and dirty" Allowing templates with the other types was something that I was thinking of. The concern was making sure it didn't break existing function.
Quote:
Another thought: my guess is that the path to the file is tacked onto the end of the command after the arguments.
That's exactly what is happening. By adding the "TEMPLATE" type, I could easily bypass that. Of course, it wasn't as simple as that.
Quote:
I can easily imagine cases where that isn't what one wants. If one can use the template processor in any argument list then the user can put the filename wherever it is needed. The trick is to put the path where the template processor can find it. I suggest that sticking it into an "odd" identifier is the best way to go. Something like the following:
Code:
def init_cache(library_path):
	from calibre.db.backend import DB
	from calibre.db.cache import Cache
	backend = DB(library_path)
	cache = Cache(backend)
	cache.init()
	return cache

from calibre.ebooks.metadata.book.formatter import SafeFormat
	
cache = init_cache(library_path = sys.argv[1])
formatter = SafeFormat()

# Loop through all the books in the library
for id_ in cache.all_book_ids():
	mi = cache.get_metadata(id_)
	mi.set_identifier("**filepath", cache.format_abspath(id_, "epub"))
	print(formatter.safe_format("{title} {tags} {identifiers:select(**filepath)}", mi, _('TEMPLATE ERROR'), mi ))
Using this idea would require you to know that the argument template is taking care of paths so you don't stick it at the end. Perhaps a second prefix is the best way to go, something like "{PATHTEMPLATE}". If you do this then you would not need the "TEMPLATE" type because the user would have control over if and where the path string is put.
OK, that's interesting idea. I was thinking of simply putting a marker of some sort in and if it exists, replace it with the file path, otherwise, add the path to the end like the plugin currently does.

And thinking of this, the "TEMPLATE" type should be "NONE" which would be "don't add the file name at all". But, it isn't as needed if all formats allow templates.
davidfor is offline   Reply With Quote
Advert
Old 05-02-2015, 07:27 AM   #261
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Vortex View Post
Thanks for trying that out, David.

Using the exact settings as above, I get the 'Everything' error message:

Unable to open file list: C:\Users\-\Desktop\-search <Authors Name> <Book Title> is not a valid file list.

Which is odd as neither the book nor 'Everything' are located on the desktop.

If I remove all the Args so the box is empty, it then opens an empty Everything search box.
OK, I'm not surprised there was a problem, but I wasn't expecting that. I have installed Everything search so that I can do the testing properly.

The plugin was not building the command line in the way I thought. I have attached a version that fixes this. When creating the Open With entry, the search string must be enclosed in quotes. So, set the "Args" to something like:

-search "{authors}"

Quote:
The (Search the Internet) plugin cant seem to handle any filename with spaces, so as it is above it does nothing. If I change the file location to one with no spaces and remove the Args after the .exe then it will open 'Everything' with no search term passed. Putting anything after the .exe stops even that from working.
Yes, because it is building a URL and they cannot have spaces in them.
Quote:
Using the webrun: protocol ( http://www.webrunapps.com/ ), which is the same idea as the AHK solution that Chaley suggested:

webrun:C:\Everything\Everything.exe -s {title}

That opens everything with the search term passed but with + symbols between every term. If I put title (and/or author) into double quotes it gives the error "not a valid file list"
Again, because it is building a URL and they cannot have spaces in them. And + symbol is usually used to connect search terms in a search URL.
Quote:

My next idea was to use some kind of intermediary like a batch file to send the search term to, clean out the + symbols and then pass it on to 'Everything'.
Yes that should work.
Attached Files
File Type: zip Open With-beta2.zip (104.8 KB, 289 views)
davidfor is offline   Reply With Quote
Old 05-02-2015, 08:57 AM   #262
Vortex
Groupie
Vortex began at the beginning.
 
Vortex's Avatar
 
Posts: 171
Karma: 10
Join Date: Dec 2008
Device: Likebook Mars
Working perfectly

Also works OK with:

-search "{title}"

-search "{authors} {title}"

Thank you, David
Vortex is offline   Reply With Quote
Old 05-02-2015, 09:46 AM   #263
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Good to hear that it is working. I'll have a look at how to make the template use for the other formats in the next few days. And any further discussion will be over in the Open With thread.
davidfor is offline   Reply With Quote
Old 05-02-2015, 04:06 PM   #264
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,553
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
See https://www.mobileread.com/forums/sho...&postcount=231

Quote:
Originally Posted by davidfor View Post
Good to hear that it is working. I'll have a look at how to make the template use for the other formats in the next few days. And any further discussion will be over in the Open With thread.
@davidfor - Does that imply that it won't work on a book with no format files?

I would have thought that that could be exact situation for doing a local search with something like Everything - "I'm sure I had this darn thing somewhere"

I guess one could use the cover.jpg or metadata.opf as the designated file type.

Should I move the relevant posts from search the internet into here ?

BR
BetterRed is offline   Reply With Quote
Old 05-02-2015, 11:52 PM   #265
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
BR: A couple of posts further up I suggested the format "NONE", maybe "ALL" would be a better term. "NONE" suggests no formats, but "ALL" would be for any book no matter what format. Working that out is one of the reasons I labelled what I did as a "quick and dirty" change. Suggestions for how to do it are welcome.

As to moving the posts, I don't mind either way. We have a cross-reference now, so they won't get lost.
davidfor is offline   Reply With Quote
Old 05-03-2015, 01:16 AM   #266
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,553
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@davidfor - the 'hangup' I have with the additional functionality being tacked onto the Open With PI is that it 'prolongs' the life of the PI, which, IMO at least, has for all intents and purposes been replaced with the recently added built in Open with functionality.

I uninstalled the PI and its json and html files as soon as I could. Primarily so I didn't have Open With and Open with sections in Preferences->Keyboard. I would think new users (even existing ones) could get easily get confused between the two - this is not the PI.

Click image for larger version

Name:	Screenshot - 2015-05-03 , 15_00_12.jpg
Views:	409
Size:	30.4 KB
ID:	137847

I'll leave it at that.

BR
BetterRed is offline   Reply With Quote
Old 05-03-2015, 01:46 AM   #267
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Perhaps a minor rename would be in order. Anyway, the plugin does sterling service on Windws XP I shuld think, also the builtin feature doesn't allow editing the cover metadata of the book record.
eschwartz is offline   Reply With Quote
Old 05-03-2015, 02:00 AM   #268
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
Quote:
Originally Posted by eschwartz View Post
Anyway, the plugin does sterling service on Windws XP I shuld think, also the builtin feature doesn't allow editing the cover metadata of the book record.
As long as it works it'll have a place in my context menu for the ability to edit covers alone.
DoctorOhh is offline   Reply With Quote
Old 05-03-2015, 02:31 AM   #269
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: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can edit covers with the builtin open with by right clicking on them in the book details panel.
kovidgoyal is offline   Reply With Quote
Old 05-03-2015, 03:08 AM   #270
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
Quote:
Originally Posted by kovidgoyal View Post
You can edit covers with the builtin open with by right clicking on them in the book details panel.
I haven't been on top of the changes recently. Thanks for the info.
DoctorOhh is offline   Reply With Quote
Reply

Tags
conversion, kepubify


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Search the Internet kiwidude Plugins 433 04-01-2024 05:48 PM
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 12:11 PM
Gui confusements. brewt Calibre 8 12-30-2008 12:16 PM
Reference Open eBook Forum: Open eBook Publication Structure. IMP. V1.0.1 14 September 2007 DaleDe IMP Books 0 09-14-2007 05:06 PM
iLiad GUI for the iLiad tribble iRex Developer's Corner 1 06-01-2007 02:29 PM


All times are GMT -4. The time now is 03:41 PM.


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