[Surfraw-devel] Hmm...how best to implement this...?
James Rowe
jnrowe at gmail.com
Mon Feb 8 02:47:56 UTC 2010
Excerpts from Ivy Foster's message of Sun Feb 07 22:05:34 +0000 2010:
> One of the search engines I use most often, as somebody who works with books,
> is [bookfinder][1], an excellent book search aggregator. Naturally, the idea of
> skipping the web forms and just running `sr bookfinder ...' appeals to the
> purist in me.
>
> [1]: http://www.bookfinder.com/
> "Search for new & used books, textbooks, out-of-print and rare books"
>
> Anyway, there are three important items to search: title, author, and isbn.
> Using isbn is simple enough; you don't really need anything else, so I figure
> it could work to just have a `-isbn=' switch. But it's pretty common to need to
> search by both title and author. Is the best way to handle this to have have
> the title be the search arg (`sr bookfinder bury my heart at wounded knee'),
> with a switch such as `-author="dee brown"', and turn off surfraw's magic
> quoting? If not, any suggestions as to what would be a better way to go about
> this?
I might be tempted to just stuff everything in to the title parameter,
as the search engine seems to cope with that ;) More seriously...
Given that ISBN and author+title searches are exclusive[1], how about
making them a little magic?
An -author flag and args would be considered a title, as in your
description. And then, Iff title appears to be an ISBN send it as an
ISBN instead. Checking for an ISBN can be done like this:
check_isbn() {
# The real function would use grep's -q option.
echo $@ | tr -d ' -' | grep -E '^([0-9]{13}|[0-9]{9}[0-9Xx])$'
}
check_isbn this is a test # fail
check_isbn 155622911x # isbn-10
check_isbn 1556- 22-911-9 # isbn-10
check_isbn word 155622911x # fail
check_isbn 123123 # fail
check_isbn 9780521871723 # isbn-13
If people use something other than ' ' or - to separate ISBNs it would
need tweaking, but it /shouldn't/ be an issue.
1. H.G Wells didn't write many Haskell books - http://tinyurl.com/y9wbhap
--
Thanks,
James
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/surfraw-devel/attachments/20100208/4e06c96c/attachment.pgp>
More information about the Surfraw-devel
mailing list