LibraryDroid tracks your books

Here’s me: I have an android phone, I can program, I use LibraryThing for tracking my books. Here’s how those things come together.

I saw that there is an Android application called A.S.E. that gives you a Ruby or Python scripting environment. One of their examples shows you how to scan a book barcode and look the book up on Google books.

A few minutes later and I’ve got it working with LibraryThing.

Updated for latest sl4a version.

That’s the openness I’m talking about. No approvals, because the phone is mine, not Google’s or Apple’s. I love it. It is awesome that I hacked that together and wrote this post, both on my phone.

You want to make it easy to add your books to LibraryThing? Just download the Android Scripting Environment, create as script with that code, and save it on your phone’s home screen. Boom! You’ve got a LibraryThing application!

This is the kind of instant little hack you get with openness.

But wait, there's more

14 thoughts on “LibraryDroid tracks your books

  1. This is a great use for Android. We are getting ready to move and my wife wanted to catalog all of her books as she was boxing them up. I just downloaded ASE, wrote up this script (with a little modification for using it with the ZXing barcode scanner), and it worked!

    I did want to ask though, how would you recommend launching the script from the home screen. I didn't see an easy way of doing that from within ASE.

      1. Here is the code that worked for me:

        import android
        droid = android.Android()
        (id, result, error) = droid.scanBarcode()
        isbn = int(result['SCAN_RESULT'])
        url = "http://librarything.com/isbn/%d" %isbn
        droid.startActivity('android.intent.action.VIEW' url)

        I think this concept is very neat, but I found the LibraryThing web interface to be too cumbersome to make this script very useful. Once it finds the book based on the scanned ISBN, you have to click on "Add Book to Library" and then search for it on their site all over again. It would be much more useful if there was a one click method to add the book from the first page that loads.

        ASE looks like a very powerful tool and I am excited to see everything I can get it to do with these new found powers.

        BTW mattkatz, I figured out shortly after I posted this how to get the shortcuts to work. Thanks for the help!

  2. I can't get this script to work.

    With the script presented above I get the following error on line 5: TypeError: tuple indices must be integers, not str

    With aReddishGreen's script I get this error on the same line: TypeError: "NoneType" object is unsubscriptable

    Anyway, If you want the script to add books to your Librarything Library without just searching for them, you should be able to just change the URL to "http://librarything.com/addbook/%d" &isbn

    I haven't tested it yet because I can't get the script to work, but it works in my browser.

    1. Thanks for the pointer about directly adding the isbn – I'll try that out.
      I'm not sure what your problem is – the script works exactly as is on my phone… Any more details you can give me?

      You should be getting a dictionary back, not a tuple. Holler back, I'll try to help!

      1. Hi I am having the same problems Roger mentioned. tried both, got tuple indices and nonetype errors. I have a HTC Desire, firmware 2.1-update1, kernel 2.6.29, build 1.15.110, software 1.15.110
        If you want more testing or info let me know.

        1. Hi Peter – I never got the same errors you did, but I noticed this script didn't work with the latest version of android scripting environment. I've updated the main script to reflect.

          1. I'm also having this tuple not being integers error, with an HTC Legend, which is pretty close to the Desire (Android 2.1 – I downloaded the script environment today). I've tried to tidy up the code given above, since it's appearing with a lot of extraneous HTML for me.

            import android
            droid = android.Android()
            code = droid.scanBarcode()
            isbn =int(code['result']['extras']['SCAN_RESULT'])
            url = "http://librarything.com/isbn/%d"&isbn
            droid.startActivity('android.intent.action.VIEW', url)

            Any tips appreciated!!

        2. I'm also having this tuple not being integers error, with an HTC Legend, which is pretty close to the Desire.

          To be honest, the script snippet displayed in the post is not that great, since it seems to have a pile of extraneous HTML in it, which for a non-developer, makes troubleshooting the thing more difficult. Here's what I have:

          import android

          droid = android.Android()

          code = droid.scanBarcode()

          isbn = int(code['result']['extras']['SCAN_RESULT'])

          url = "http://librarything.com/isbn/%d"&isbn

          droid.startActivity('android.intent.action.VIEW', url)

          1. This is what i did to solve this error:

            import android
            droid = android.Android()
            (id, result, error) = droid.scanBarcode()
            isbn = int(result[‘extras’][‘SCAN_RESULT’])
            url = “http://librarything.com/isbn/%d" %isbn
            droid.startActivity(‘android.intent.action.VIEW’ url)

            I hope this helps you.

    2. I added your hint, and I also updated the script to work with the latest version of ASE. Try downloading the latest version and give the script another go if you could. Thanks!

  3. I keep getting an error about unexpected "(" on line 3 which reads…
    droid = android.Android()

    when I saved the script ASE gave it a .sh extension. Should it have been .rb or .py instead?

    1. just for posterity's sake – I think your problem was that it should have been a .py – do let us know

Leave a Reply to trixtah Cancel reply

Your email address will not be published. Required fields are marked *