09-01-2008, 12:46 PM | #1 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
impfind and impfindGUI
This is short command line perl script and a longer gui version, that will search a directory for imp ebooks and display information about them. It uses switches to determine what you want to search for and how. Place the script somewhere in your path and set the executable bit.
There are a few caveats for now. Searching for more than one field doesn't work right now. In version 0.2 the default behaviour is to search all fields. The a, c, and t switches can be used to search for author only category only or title only. Searches are always case sensitve. In version 0.2 the -S switch can be used to force case sensitive searches, otherwise the default behaviour is case insensitive. The script works in windows xp with perl installed but doesn't display the path seperators correctly. Path seperators in version 0.2 should work in whatever os you are using. I also don't know how it wil handle truly large numbers of files. I didn't test it with more than about 50. Examples: Code:
impfind.pl -h impfind version 0.2 impfind [-hRSflact] directory space seperated list of keywords to search for impfind -i path to book -h help this short help list and the version -R Recurse through subdirectories -l list the information for all located books. Category, Title, Author -S Sensitive to Case Searching -f full search results the default is just to give a list of paths -V Verbose gives lots of information very little of which is much use to most people. Used for a closer look at what is going on for debugging -i path to a book to show information about If the following switches are omitted impfind will search all three of fields for any of the keywords. -a Search only the Author field for the keywords -t Search only the Title field for the keywords -c Search only the Category field for the keywords Code:
impfind.pl -R /home/derrell/Books/EB1150 moon Searching /home/derrell/Books/EB1150 for files ending with .imp Searching through sub directories. Getting information for 37 Books Found 1 Books Containing moon /home/derrell/Books/EB1150/Ringo/East_of_the_Sun_and_West_of_the_Moon.imp Code:
impfind.pl -Rf /home/derrell/Books/EB1150 moon Searching /home/derrell/Books/EB1150 for files ending with .imp Searching through sub directories. Getting information for 37 Books Found 1 Books Containing moon Path: /home/derrell/Books/EB1150/Ringo/East_of_the_Sun_and_West_of_the_Moon.imp Category: Science Fiction Title: East of the Sun West of the Moon Author: John Ringo Code:
impfind.pl -R /home/derrell/Books/EB1150 tarzan moon apes son Searching /home/derrell/Books/EB1150 for files ending with .imp Searching through sub directories. Getting information for 37 Books Found 11 Books Containing tarzan moon apes son /home/derrell/Books/EB1150/Burroughs/Tarzan/Tarzan_of_the_Apes_hd.imp /home/derrell/Books/EB1150/Burroughs/Tarzan/Tarzan_of_the_Apes.imp /home/derrell/Books/EB1150/Burroughs/Tarzan/Beasts_of_Tarzan.imp /home/derrell/Books/EB1150/Ringo/East_of_the_Sun_and_West_of_the_Moon.imp /home/derrell/Books/EB1150/Burroughs/Tarzan/The_Son_of_Tarzan.imp /home/derrell/Books/EB1150/Burroughs/Tarzan/The_Son_of_Tarzan_hd.imp /home/derrell/Books/EB1150/bookshelf/shelf/The_Return_of_Tarzan.imp /home/derrell/Books/EB1150/bookshelf/shelf/Beasts_of_Tarzan.imp /home/derrell/Books/EB1150/Burroughs/Tarzan/The_Return_of_Tarzan.imp /home/derrell/Books/EB1150/bookshelf/shelf/Tarzan_of_the_Apes.imp /home/derrell/Books/EB1150/bookshelf/shelf/The_Son_of_Tarzan.imp Code:
impfind.pl -a Scalzi Searching /home/derrell/Books/EB1150/ for files ending with .imp Getting information for 7 Books Searching Author fields for: Scalzi Found 1 Books /home/derrell/Books/EB1150/JohnScalzi-Old_Mans_War.imp Code:
impfind.pl -Ra Scalzi Searching /home/derrell/Books/EB1150/ for files ending with .imp Searching through sub directories. Getting information for 37 Books Searching Author fields for: Scalzi Found 1 Books /home/derrell/Books/EB1150/JohnScalzi-Old_Mans_War.imp You can request information on a specific book with -i switch. No other switches will be looked at when -i is used. Code:
impfind.pl -i /home/derrell/Books/EB1150/Ringo/East_of_the_Sun_and_West_of_the_Moon.imp Information for /home/derrell/Books/EB1150/Ringo/East_of_the_Sun_and_West_of_the_Moon.imp id: ebook:guid-bfbf259a5b8111ddff910013d4244fc9 category: Science Fiction sub_category: outPages=585&inPages=904 title: East of the Sun West of the Moon author_last: author_mid: author_first: John Ringo 09/01/08 added version 0.2 of the script and changed the instructions on how to use it. Edit/ 09/02/08 Fixed bug with single command line switch. Version 0.2.1 Edit: 09/13/08 Added gui version 0.3 Edit: 09/13/08 Added version 0.3.1 to fix windows help bug. Edit: 09/19/08 Uploaded version 0.4 many improvements and new bugs Edit: 09/21/08 Uploaded version 0.4.1 changed things around some more. Last edited by derrell; 09-21-2008 at 09:56 AM. Reason: attaching script |
09-01-2008, 03:51 PM | #2 |
Addict
Posts: 350
Karma: 705
Join Date: Dec 2006
Location: Mumbai, India
Device: Kindle 1/REB 1200
|
Hey, this is cool! I'd like to make a few suggestions:
1. Make searches case-insensitive (convert everything to lowercase) 2. Making the command line syntax something like impfind <dir> <keywords> [-options] would search through ALL fields would be better (you might optionally specify -a to specify search on authors only) Also, ignore the sub-category and author-mid + last name -- they are never set correctly in any IMP book I have seen. |
Advert | |
|
09-01-2008, 04:30 PM | #3 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
The case insensitive searching is on the list. Insensitive as the default with switch to force it to pay attention to case. Also the order for dir and keywords to search on looks better.
Something like impfind Books/ space seperated list -R I'll work on it some and post another version. |
09-01-2008, 06:38 PM | #4 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
I think that I have the windows path seperator thing taken care of and also changed around how the command line works like ashkulz suggested. Except it is <switches> directory keywords. I'll edit the first post to match how version 0.2 works now.
|
09-13-2008, 02:22 AM | #5 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
impfindGUI
I've added a simple gui to the impfind script. Version 0.3 has both the command line version and the gui version. They work independent of each other so you can install just one of them or both. It really doesn't do much at this point except provide a gui to the search for imp format books. I plan on adding the ability to copy files selected in the search tab to a directory that can be used as your bookshelf. That way I can search for the books I want on the reader without having to hook the reader to the computer first.
The gui is Tk so that will need to be installed. My base install of ubuntu did not have Tk installed so a quick look through synaptic was required to install it. In windows it seems to work alright as well although I didn't do any extensive testing there. You will need to have perl installed and ActiveState perl has the Tk libraries so the script should work fine. The perl code for now is really ugly and most likely full of bugs. Before I release any other versions I plan on cleaning it up before it gets any longer. Last edited by derrell; 09-13-2008 at 02:27 AM. |
Advert | |
|
09-13-2008, 02:34 PM | #6 | |
GuteBook/Mobi2IMP Creator
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
|
Quote:
Code:
E:\ebooks\Impfind\impfind-0.3>impfindGUI.pl Searching through sub directories. Tk::Error: bad option "-font": must be -default, -icon, -message, -parent, -title, or -type at C:/Perl/lib/Tk.pm line 320. Tk callback for tk_messageBox (menu invoke) Code:
This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 50 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 820 [274739] provided by ActiveState http://www.ActiveState.com Built Jan 23 2007 15:57:46 Code:
Tk - a Graphical User Interface Toolkit Version: 804.027-r6 Released: 2006-07-31 Author: Nick Ing-Simmons <nick@ing-simmons.net> CPAN: http://search.cpan.org/dist/Tk-804.027/ Oh, in the GUI, usually clicking the 'column head' allows that column to be sort ascending; another click sort descending. Could that be easily implemented using Tk? Great job. I posted Imp Librarian for windows a while back; you may want to look at it's features for your next release (or two )! |
|
09-13-2008, 08:03 PM | #7 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
Fixed the help bug under windows I think with version 0.3.1. Looks like for some reason there is no -font option for messageBox in the windows Tk. Script now checks to see if it running under windows or linux.
|
09-19-2008, 01:27 PM | #8 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
Uploaded version 0.4
Several new things. There is now a tab to display the directory that is being used as the bookshelf. From the Search tab you can now select books and copy them to the book shelf and in the shelf tab you can delete all of the books or selected ones. Both lists can now be sorted by clicking the header of the column that wants sorting. I also tried to clean up the code some and make it a little more readable. |
09-19-2008, 03:04 PM | #9 | ||
GuteBook/Mobi2IMP Creator
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
|
Quote:
Quote:
I'll be looking for those new bugs shortly... |
||
09-21-2008, 10:05 AM | #10 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
impfind, impfindGUI ver 0.4.1
Changed things around some more. The Gui can now search for imp, mobi, and zip book files. If mobils is installed it can get information from the mobi files, title and author, but it is sort of slow and doesn't always give back any useful information. With the zip files you just get a file name and the script makes a guess from that as to what it really is.
You can also now preview the imp and mobi files from the Search tab if you have the eBook Publisher viewer installed and something that will render mobipocket like FBReader. Set the paths and commands in the Configure tab. I also added graphics to some of the buttons, the images are in the ImpFind directory that is included in the archive. Where ever the scripts are installed the ImpFind directory needs to be a subdirectory of that. The script can then find them. |
09-21-2008, 10:21 AM | #11 |
GuteBook/Mobi2IMP Creator
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
|
Swiss-army knife of the .imp world!
Great job, derrell! |
09-26-2008, 06:51 PM | #12 |
GuteBook/Mobi2IMP Creator
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
|
Any way to resize the columns in the GUI version? I had one really long category description (created by Lit2sb) that enlarged the column to accomodate it (but not what I wanted ). I wanted it shrunk down to the next largest (or user inputted) size.
I'm not familiar with Tk, but can this be done easily? |
09-26-2008, 07:47 PM | #13 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
I'm not sure but I think that an extra module has to be installed. resizebutton or something like that and I didn't use that one. So I guess the short answer is no I don't think so. I'll look at it and see if there is an option that I left out of the code that will allow that though. Most folks expect to be able to resize the columns.
|
10-17-2008, 11:49 PM | #14 | |
GuteBook/Mobi2IMP Creator
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
|
Quote:
Searching, after the inital load, takes no more than 10 seconds. BTW, a few comments/requests (if you are still developing this tool): (1) can the viewer button be placed on the Book Shelf tab as well? (2) can you make the Path pane sortable too like Category, Title, Author and Type? (3) can each successive header click toggle the sort order/direction between ascending and descending. ~~~~ OK, personal favour time. How do I start adding a Tk GUI to an existing .pl script that I have; do I create the GUI part using an editor? Any tips you may have would be helpful-linux or windows! BTW, I found this code for Tk Tag (an MP3 ID3 tag editor) and would like to extend it to a .imp meta header editor! But where do I start... |
|
10-18-2008, 12:36 AM | #15 |
Jack O' Apes
Posts: 227
Karma: 1939
Join Date: Dec 2007
Location: Oklahoma
Device: Ebookwise 1150, Nokia N810, EZ-Reader, HTC Droid Incredible, Archos 70
|
There are a couple of GUI tk interface creators like Zooz but I find it easier to just add the code by hand as I build up the interface. One of the major drawbacks of Tk is that as the application gets larger and more complicated you tend to end up with global variables all over the place. There are object oriented solutions to this but I generally end up using hashes for them. Oop and I don't get along well, one of the reasons that I still use perl for most things that I write and haven't really gotten into python where everything is an object.
Here are a couple of links for some basic Tk info. There are many around the web. Tk tutorial Zooz My opion though is that it easier to just code the ui. Some more advance widgets. Oh and I'm still tinkering with this some but I think I'll be moving to an epub like storage system for my books. Where the book is exploded into an oeb style structure with either mobi2oeb or convert lit then modify the opf file and build an imp with a short windows script that wrote that uses the BookMill com interface. From there I can store the imp file and all of the other files in a single zipped archive or possibly bzip2. That will give easy access to the created imp file so it can be copied to my bookshelf or to easily change the metadata in the opf and rebuild the imp. The impfindGUI script will most likely be the starting point with some modules added to handle manipulating the book files. The sort for the path and the button on the shelf tab shouldn't be hard to add. I'll look at adding that to the what I have and post another version in a couple of days. Last edited by derrell; 10-18-2008 at 12:55 AM. Reason: premature publish |