YTMND Snippets

Posted by Jason Sun, 26 Jun 2005 09:42:00 GMT

Perhaps my favorite site on the internet is You’re The Man Now Dog. I usually spend at least 15 minutes a day just hitting random YTMNDs and generally laughing my ass off.

Of course, I am also a cyber-packrat, so if I find a YTMND funny, I’d bookmark it. There are two problems with this approach. First, the giant YTMND folder is in my bookmarks is very awkward. After I got a few hundred entries in there, Safari started to choke whenever I added a new bookmark. But more importantly, this approach is dependent on YTMND being available forever and ever. It’s gone down once… And considering how much bandwidth and storage it requires, I’m guessing it’ll go down again. So there was only one course of action: save all my favourite YTMNDs locally.

My first attempts at doing this with perl’s WWW::Mechanize and HTML::Manipulator modules was unsuccessful. So I backpedalled and figured out that the right way to do this was with wget. This command will download the index page, the background, the sound, and blank.gif into the current working directory:

wget -S -U "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/124 (KHTML, like Gecko) Safari/125" -r -l1 --span-hosts --no-directories --convert-links --follow-tags=body,embed,img http://tcruiseko.ytmnd.com/

The important thing here is to -U argument. YTMND does some browser sniffing to determine how to embed the sound. If you don’t include that argument, it will embed it in a way that looks ugly in Safari – the Quicktime sound control will appear in the top left.

I wrote a perl script to handle the directory structure automatically. I now have a directory with a ton of YTMNDs, and browsing through it fills me with joy.

Next step was extracting all my bookmarked YTMNDs and saving them with my script. Safari’s bookmarks file is just XML. EASY!

cat ~/Library/Safari/Bookmarks.plist | grep ytmnd | perl -e 'while ( <STDIN> ) { chomp; ( my $url ) = ( m|(http://[^/]+/)| ); print $url . "\n"; }' | ~/Projects/ytmnd/ytmnd.pl

This is still executing as I write this. I’ve got over 800 of these bookmarked. Perl makes life so much better.

Comments

Trackbacks

Use the following link to trackback from your own site:
http://blog.thelegendarybeek.com/articles/trackback/4

(leave url/email »)