Skip to main content

Ralsina.Me — Roberto Alsina's website

Goodreads+webcam+python+zbar == hackfun!

I am a big fan of GoodReads a so­cial net­work for peo­ple who read book­s.

I read a lot, and I like that I can see what oth­er peo­ple think be­fore start­ing a book, and I can put my short re­views, and I can see what I have been read­ing, and lots more.

In fac­t, goodreads is go­ing to be a big part of a project I am start­ing with some PyAr guys.

One thing I have been lazy about is adding my book list to goodread­s, be­cause it's a bit of a chore.

Well, chore no more!

Here's how to do it, the hack­er way...

  1. Get zbar

  2. Get a cheap we­b­­cam

  3. Get a book

  4. Get a 7-­­line python pro­­gram (in­­clud­ed be­low)

Now watch the video...

Cute, is­n't it?

Here's the code:

import os

p=os.popen('/usr/bin/zbarcam','r')
while True:
    code = p.readline()
    print 'Got barcode:', code
    isbn = code.split(':')[1]
    os.system('chromium http://www.goodreads.com/search/search?q=%s'%isbn)

PET: English Translation Issue 1 has a date

Be­cause it worked on­ce, let's do it again. I have just set a com­plete­ly ar­bi­trary, and prob­a­bly too ear­ly date for the re­lease of the first eng­lish Is­sue of "PET: Python En­tre To­dos" mag­a­zine.

The eng­lish ver­sion is called PET, which means "Python En­tre To­dos: Eng­lish Trans­la­tion".

It will have the same con­tents as the first span­ish Is­sue and... it will be the last Is­sue done like this.

From now on, both ver­sions will be pub­lished at the same time, if we can.

So, there will be a very short gap be­tween the eng­lish first Is­sue and the sec­ond one (less than a mon­th, we hope).

So, stay tuned

I'm a nerd, but I Have a Cheap Phone

I just got a new phone be­cause my old one dis­ap­peared. I got a Sam­sung Star, which is not a smart­phone, but what they call a fea­ture­phone, which seems to mean "it does a lot of things but is cheap, can on­ly be cod­ed in Ja­va and does­n't run an­droid".

Here's some of the fea­tures of this baby:

  • Touch­screen, 400x240

  • Fake GPS (gives you a 400 me­ters ra­dius of your lo­­ca­­tion. Good enough for me in the city)

  • We­bkit-based brows­er that works sur­pris­ing­­ly well (it comes with the LGPL as a doc­u­­ment and you can't delete it :-)

  • Ac­celerom­e­ter

  • FM ra­­dio

  • A 2GB mi­cro-SD card

  • 3.2MP cam­era (takes video at 320x240).

The cam­era can take de­cent pho­tos in good con­di­tion­s:

Foto0005.jpg

And it even has some "ad­vanced" fea­tures (by which I mean: things my cheap ded­i­cat­ed cam­era does­n't do), like smile shut­ter and panoram­ic shot­s:

Foto0018.jpg

Oth­er that that... well, it's a phone, what can I say. It was "cheap­", which means "it costs more than I want to pay for it, but less than the al­ter­na­tives".

So, how am I tak­ing ad­van­tage of it...

First: I have not had a de­cent pock­et-­sized ebook read­er since my last Clie died. So, I looked for soft­ware to do that.

It turns out that the world of Mi­dlet­s, as fea­ture phone apps are of­ten called, is aweird place, where things are quite hard to find for the unini­ti­at­ed.

There is a sort of "app shop" at http://get­jar.­com but it's by no means com­pre­hen­sive, and of­ten things are quite hard to find.

Af­ter lots of look­ing, I found a good (I may even say very good) pro­gram called Fo­liant. Here's their home page, rus­sian on­ly ... it's weird, my favourite Palm ebook read­er, Palm Fic­tion al­so has a rus­sian-on­ly site!

Of course, the fonts sucked (way too large) but it turns out you can con­vert TTF fonts us­ing this tool so I am now back to the love­ly Droid Sans I am used to.

An­oth­er nice thing about the new phone is that it can ac­tu­al­ly play me­dia (yes, my pre­vi­ous phone was so crap­py it did­n't even play mp3). But... not ev­ery kind of me­di­a. For au­dio, just use mp3. For video... it's a bit more com­pli­cat­ed.

Here's the short ver­sion:

  1. Con­vert us­ing Hand­Brake, ffm­peg MP4 video, AAC au­­dio.

  2. Al­ways use the .m­p4 ex­ten­­sion, the phone is not smart enough to know what a .m4v is.

  3. Don't make the video larg­er than 320x240.

Num­ber 3 is a prob­lem. For ex­am­ple, you may have a video in a wide screen for­mat, like 640x272, which is a 2.35:1 ra­tio.

The ob­vi­ous thing is to cap the width to 320, and that would give you a 320x136 video.

Well, that's wrong. What you should do is find the right height, keep­ing as­pect ra­tio, for a 400px width. In this case, that would be a 400x170.

But you can't use a 400x170 video! which is why you will use 320x170, and on play­back tell the phone to stretch it and ig­nore as­pect ra­tio. And voila, 400x170 and the cor­rect as­pect ra­tio.

The dif­fer­ence? 320x130 has on­ly 41600 pix­el­s, while 320*170 has 54400, which means you get a 30% bet­ter pic­ture.

Yes, it's tiny (3 inch­es) but it looks pret­ty sharp, and de­pend­ing on the kind of ma­te­ri­al you are watch­ing, it work­s.

UP­DATE: Fo­liant is bet­ter than I thought, once you get the Sam­sung-spe­cif­ic ver­sion. It's fullscreen (no sil­ly soft but­ton­s) and the screen ro­tates au­to­mat­i­cal­ly us­ing the ac­celerom­e­ter. It's a plea­sure to use, and the UI is very nice.


Contents © 2000-2025 Roberto Alsina