Mobileread
impfind
#1  derrell 09-01-2008, 11:46 AM
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
To search a directory for books with the word moon in the title, author, or category fields recursively.
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
To search a directory for books with the word moon in the title, author, or category fields recursively and display the full book info.
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
To search a directory for books with the words, tarzan moon apes son, in the title, author, or category fields recursively.
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
Using the directory that impfind.pl was started in and searching for books by Author Scalzi
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
Add the -R switch to make it look through all of the directories below where it was started.
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
Edit/
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.
[pl] impfind.pl (3.9 KB, 1153 views)
[zip] impfind-0.2.zip (5.6 KB, 1286 views)
[zip] impfind-0.2.1.zip (2.3 KB, 1245 views)
[zip] impfind-0.3.zip (11.1 KB, 1250 views)
[zip] impfind-0.3.1.zip (18.4 KB, 1280 views)
[zip] impfind-0.4.zip (19.9 KB, 1283 views)
[zip] impfind-0.4.1.zip (32.5 KB, 1250 views)
Reply 

#2  ashkulz 09-01-2008, 02:51 PM
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.
Reply 

#3  derrell 09-01-2008, 03:30 PM
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.
Reply 

#4  derrell 09-01-2008, 05:38 PM
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.
Reply 

#5  derrell 09-13-2008, 01:22 AM
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.
impfindGUI1.png impfindGUI2.png 
Reply 

#6  nrapallo 09-13-2008, 01:34 PM
Quote derrell
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.
I tried this in windows and it works ok, except for a minor glitch using the GUI help menu. I got the following error (and no help showed up ):
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)
I have this version of perl installed on my WinXP computer:
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
with this Tk package already installed:
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/
One suggestion for your next release, allow at least one field to be (quick) sorted; with the user selecting which one.

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 )!
Reply 

#7  derrell 09-13-2008, 07:03 PM
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.
Reply 

#8  derrell 09-19-2008, 12:27 PM
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.
impfindGUI-04-1.png impfindGUI-04-2.png 
Reply 

#9  nrapallo 09-19-2008, 02:04 PM
Quote derrell
Edit:
09/19/08 Uploaded version 0.4 many improvements and new bugs
Quote derrell
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.
Wow, looks like you have made some great improvements!

I'll be looking for those new bugs shortly...
Reply 

#10  derrell 09-21-2008, 09:05 AM
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.
impfindGUI-041-1.png impfindGUI-041-2.png impfindGUI-041-3.png 
Reply 

  Next »  Last »  (1/3)
Today's Posts | Search this Thread | Login | Register