11 June 2006

Gawker Image Fetch Script

There’s not a lot more to it than the title suggests. I’ve made a script you can use to fetch webcam images from any host on the Internet that’s running Gawker.

The script takes arguments of the host and port to connect to as well as the file to overwrite with the latest exciting image. Together with some javascript you can do neat things like have a live updating webcam image.

Silly things like half-written images are dealt with, but that means the directory that has the image file in it needs to be writable. If the camera sends images faster than your local machine can write out to disk, that’s bad. So don’t do that.

In the future, I’ll make changes that fulfill desires I have, like producing a timelapse movie of the last 24 hours. And more complicated, a timelapse movie that skips the dark frames in the night that are less interesting.

After a few minutes of thought: Future changes like reconnecting in the event of a failure spring to mind as well. For now though, this is scratches-an-itch-ware.

Update: My script now resides at Google Code with the code available in Subversion at http://gawker-image-fetch.googlecode.com/svn/trunk/. It now supports finding cameras with Zeroconf and reconnecting automatically.

Later Update: New features are appearing, like support scripts for doing time-lapse movies. Check the code site for the latest information.

4 comments:

Unknown said...

Hey great script, man! Exactly what I was looking around for since Gawker always seems to crash for me after recording hours of video. I can't seem to establish a connection to the Gawker cam tho:

$ python gawker_img_fetch.py -f outputfile.jpg -d ~/Sites/brewerycam --bonjour="BreweryCam" --foreground
gawker_img_fetch.py [77756]: Starting gawker_img_fetch 6 (in foreground)
gawker_img_fetch.py [77756]: Watching zeroconf for 'BreweryCam._lapse._tcp.local.'
gawker_img_fetch.py [77756]: Starting zeroconf service browser
gawker_img_fetch.py [77756]: Creating reader object
gawker_img_fetch.py [77756]: <__main__.GawkerListener object at 0x2ed890>
Traceback (most recent call last):
File "gawker_img_fetch.py", line 348, in < module >
if __name__ == "__main__": sys.exit(main())
File "gawker_img_fetch.py", line 335, in main
options.directory)
File "gawker_img_fetch.py", line 60, in __init__
self.poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'

Do you have any clues or debugging tricks that would me troubleshoot the problem? Thanks again.

Unknown said...

UPDATE: I was trying to run this on Mac OS X Leopard, which doesn't come with select.poll() compiled in Python. I simply installed the latest python from python.org and everything is working out swimmingly.

Thanks for the fantastic script!

wac said...

Interesting that they'd leave select.poll out of their build. OS X's kernel has support for both poll(2) and kevent/kqueue(2) so I'm baffled as to why they wouldn't include this in the default build they ship to users. Although now that I review various email archives it looks like poll(2) has been broken in historic versions of OS X (10.4.2 and earlier).

I might be able to generate some sort of workaround that uses select.select() instead.

I've created a bug report about this problem, thanks for looking into it on your own too.

wac said...

I've update Gawker Image Fetch to use select.select() when select.poll() is unavailable. The fix is on the tip of the trunk. I'll post to the blog with a link to it later.