Thursday, September 16, 2004

Super Nerd

The lesson I learned the last two weeks is that it is a pain in the butt to go through a Now Playing list of songs and try to determine which albums had been listened to over a period of time.

I posted rough lists of albums twice (here and here) by hand before I decided that doing it manually wasn't going to cut it. I would invariably miss some albums, or get things out of order, and had no easy way to indicate what one-off songs I had also made it through.

So, last night and tonight I put together a really lame system to automate the process. So far, it goes like this:

The blogging plug-in for WMP updates the registry with the song title/artist/album information when a song is playing.

A perl script runs as a service (using srvany.exe from the Windows resource kit). It looks through the HKEY_USERS key to find a key that has the MediaPlayer/CurrentMetadata key. Then it monitors the author/album/title keys for changes every 20 seconds or so. When a new song starts playing, it dumps that information to a running log file.

Then I wrote another perl script to parse through the log file, find all the songs that were played during the day and organize them into albums/one-offs. Then it outputs the information to a html file that can be posted to blogger.

The result is this.

I'm happy that the system works, considering it only took me an hour or two to get it all working (and most of that was head scratching over HKEY_CURRENT_USER not working in a service, which makes sense in retrospect). It could certainly be improved, particularly if I wasn't so lazy and just wrote a plug-in for WMP that would write the log file directly (instead of going through the whole monitoring the registry mess). However, from what I can tell, checking the registry once every 20 seconds and sleeping the rest of the time takes pretty much no CPU time, so it is not as bad as you might think.

The only part that still needs to be completed is finishing my AutoPost program, to automatically upload the html output into a blog entry. Then I can just schedule that job (or run it before I leave for the day), and the day's MP3 progress will be logged automatically posted.

However, the AutoPost program is somewhat slower going then all the perl scripts. The problem is that the way I know how to post to blogger is by using the XML-RPC interface (Blogger API 1.0 as it is called). But this method doesn't allow you to title your posts, and I really would like the posts to have sensible titles (if nothing else so people can ignore them if they find it stupid).

So then I was going to work on adapting the sample C# client to my needs, except it doesn't work. Blogger gives me back an error saying I need to send a blogID along with the request.

Which would be fine (I already know how to get that information using XML-RPC), except that I don't see where in the WSDL that the blogID should be sent.

So for now I will have to post the entries by hand (which is a pain since it is difficult to paste HTML into the editor, and not have it screw up the formatting by changing line-breaks to <br>'s.

Anyways, back to the reason for this post. If you have comments on the whole daily music post, such as how it should be formatted, if the tracks should be listed differently, or even if you just want to say 'WTF are you doing, no one wants to see this information', please let me know. Well, ok, so maybe not that last one.

6 comments:

Brenden Johnson said...

Looks pretty good yo. With this system of listing everything you listen to one of the fun activities will be to see what crappy or embarrasing songs Steve might have listened to!

Brenden Johnson said...

...like Britney - Toxic, though I have to admit that's probably the one Britney song I don't hate.

Steve Eck said...

I'll have to issue a blanket defense, that I copied a bunch of folders wholesale to the laptop. Thus I have a lot of Linzy's music as well.

Which explains the country music that showed up on the list yesterday.

Although I do have to take the blame for Toxic, that is my fault. I like (or liked, I'm kinda sick of it now) that song.

I could prune these things out, but I figured that takes some of the fun out of it. At least for those who want some humor at my expense.

wleino said...

I am saddened that Backstreet Boys : Backstreet's Back Allright isn't on the list. For my money the best crappy group/song of all time.

Brenden Johnson said...

That Backstreet song is on my bosses playlist at work. He has a considerably smaller music collection than Steve, I sometimes get to hear it twice a week.

I just cringe everytime I hear it.

Steve Eck said...

I remember when my old roomate in college was pissed because BackStreet's Back Alright started to be a big hit, and he was like:

'That song is so old, it came out in 1998 and now they are just starting to play it on MTV and the radio'.

He tried to refuse to play it at Stargate (a club in Superior where he DJ'd), and got overruled by management.

So everytime I hear the song it makes me imagine him sitting in the DJ booth pouting because he has to play this 'old' song against his will.