Archive for June, 2007

iRate.py v2007-06-29

Friday, June 29th, 2007

The Problem:iTunes keeps song ratings, play and skip counts in a proprietary database format.The Solution:iTunes exposes song ratins, play and skip counts via AppleScript, and I have a python->AppleScript bridge.My solution of course is not a particularly original one, Doug’s AppleScripts for iTunes includes a Tags to File Comments script. Which uses AppleScript to take ratings, play counts, skip counts, and more out of iTunes and shove it into the Spotlight comment field in the extended attributes. This was a fine, perfectly well functioning script. However the performance characteristics of both AppleScript and extended attributes makes it very very slow. On my Core 2 Duo MacBook Pro it took roughly 8 hours (I don’t actually know, I fell asleep while waiting) to export the data for ~4,430 tracks, with iTunes using 100% CPU. I don’t know how long it takes to import the data because I figured I could write something else in less than 8 hours.So after about 4 hours of coding and debugging I present to you iRate.pyIt uses AppleScript to export the the ratings, played count, played date, skipped count, skipped date to an SQLite database. It will also import the same data from the SQLite database.  It also manages to be significantly faster than Doug’s script.  The export of my library takes about 44 seconds, and another 22 seconds to import.To run it requires:

  • MacOS X 10.4 (tested on 10.4.10)
  • iTunes 7.2+ (tested on 7.2 and 7.3)
  • Python 2.5 (Universal binary available here)
  • appscript 0.17.2 (Fancy installer available here)

So there we have a simple solution to a simple problem. Here is hoping someone else finds it as useful as I did.-David

Technorati Tags: ,

Here is a list of 5 things that suck.

Monday, June 25th, 2007
  1. Having your car stolen.
  2. Getting charged$265 for having your car stolen.
  3. Having your passenger side door not shut after your car was stolen.
  4. Moving.
  5. Having to put off moving because your car was stolen and now needs expensive repairs.

And here is a list of things I would like to not have to move, so if you’re reading this and are in the SF bay area you are perfectly welcome to come pick them up.

  1. A Macintosh IIsi
  2. An Amstrad PPC640D
  3. A Blue&White G3
  4. A box of misc comic books and baseball cards
  5. A couple of 19-21″ CRTs (will accept 1 14-15″ CRT or LCD in trade.)

I apologize for this post having nothing to do with anything terribly interesting.

very actual information about skulls

Tuesday, June 5th, 2007

WWDC2007 is in just 5 days. I’m very much looking forward to seeing people’s reactions to Leopard Server since last year. It’s been really fun to work on, and not just because my stuff is almost all Python + Twisted. I’ve just had to work on some really interesting problems. It’s also very nice to take a break from doing a lot of framework work and never getting to really use the framework. Now I am, now I thinking I’m understanding much better what it’s actual problems are, and why some of our design decisions have been good and some have been bad. (Mostly mine have been bad I think.) I really look forward to correcting some of those mistakes in the near future once we’ve shipped. I’m also looking forward to seeing what comes of the Twisted.web2 summer of code project. James and Valentino are both very smart people and I’m sure some amazing things will get done.On a web2 related note. I’ve never been very happy with static.File. For a variety of reasons that I haven’t really documented anywhere. So here is a short list.

  • It’s poorly factored, it contains code to handle both files and directories, and it is difficult to seperate the code that does the directory listings from the files. (Even though it’s in defined on another class, it’s still weird and difficult to substitute.)
  • It doesn’t take advantage of one of web2’s most useful features over twisted.web, the ability to consume an arbitrary number of path segments during resource traversal. In theory you could join all the segments passed to locateChild and try to treat it as a file, falling back to child_ methods or children that were added with putChild if the file didn’t exist, and if that failed returning a 404. (a non-existent static.Directory class could do this, since static.File instances shouldn’t have children.)
  • There were also some things that bothered me about overriding mimetypes
  • I’m also not fond of it’s ignoredExts or processors __init__ arguments. They’re useful for executing such as CGI scripts but I don’t really think you should mix scripts you want executed with files you want served statically. Perhaps that is just an asthetic issue. We also have a CGIDirectory which acts as a general purpose cgi-bin resource.

And now, just like I promised, som every actual information about skulls. “In humans, the adult skull is normally made up of 29 bones.”P.S. If you’re confused about the title of this post, it came from a spam comment that got caught in moderation (and made it past akismet,) it amused me greatly and I at the time of this writing nothing came up on google for it.

Technorati Tags: , ,