One Aging Geek

Tuesday, June 27, 2006


So right after I was making a deal about my scripting skills I noticed that I hadn't gotten a TAL episode when expected.

I had been pulling files from the Complete Archive page. For some reason episodes are posted there a few days later than they are on the current year archive page.

So since I was feeling all pumped up I decided to change over the script to use the current year archive page. The links on the page (either the complete or the yearly) point to M3U playlist files. But between the last time I fiddled with this script and this time, the contents of the playlist has changed. Or I didn't look very closely before.

For some reason the playlist files each contain four entries. That would normally be four "tracks". So I guessed that they were now posting the episodes in four parts. Since the show is usually an intro followed by three "acts" that wasn't much of a surprise. I twiddled up the script a bit to read all four "parts" and put them in a directory where they'd eventually find their way onto my MP3 player.

To my surprise I didn't get four parts, I got four repetitions of the entire show.

My only guess at this point is based on each of the entries in the playlist having a different port. My guess is that this is some kind of poor man's load balancer. So I'm picking one at random. The script to get the archive page, find the first 10 playlist files referenced, extract the episode number, match the episode numbers against a log file that prevents duplicate downloads, fetch the contents of the playlist file and select a random entry from it is five lines of fairly dense bash script. The script that then fetches the episode, figures out where to store it, makes the directory if needed is longer because it isn't just a couple of pipelines, it's 25 lines and still has all the code to loop thru multiple parts. Without the looping and the directory creating logic it could be boiled down to a single call to "curl".

Learning to think in pipelines: priceless