Totally Stealing Your Music at OSCON

| | Comments (0)
OK, I am not stealing music, just recording what's in your shared playlist. I load your shared playlist in iTunes, and then Mac::Glue iterates over it and stuffs the data in MySQL. Then later I can do something interesting with the data.

Slash::Test provides my DB API. So if you don't have Slash installed on your Mac, you're kinda hosed. But you can drop in your own data store code.

Of course, as many people at OSCON know, the network has issues. I can't load up most of the iTunes playlists out there. Sucks. So far I've seen maybe 40 or more, but I've only been able to get about a dozen. Sucks, I say!

use warnings;
use strict;
use Mac::Glue ':all';
use Slash::Test;
my $itunes = new Mac::Glue 'iTunes';
my $slashdb = getCurrentDB();
my $shares = $itunes->obj(sources => whose(kind => equals => enum('shared library')));
for my $share ($shares->get) {
    my $sharename = $share->prop('name')->get;
    print $sharename, "\n";
    my $tracks = $share->obj(tracks => playlist => 1);
    my $i = 0;
    for my $track ($tracks->get) {
        my($artist, $album, $name) =
            map { $track->prop($_)->get || '' }
            qw(artist album name);
        $slashdb->sqlInsert('oscontunes', {
            sharename    => $sharename,
            artist        => $artist,
            album        => $album,
            name        => $name
        }, { ignore => 1 });
        unless (++$i % 100) {
            print $i, "\n";
CREATE TABLE oscontunes (
    id mediumint UNSIGNED NOT NULL auto_increment,
    sharename VARCHAR(255) NOT NULL,
    artist VARCHAR(255) DEFAULT '' NOT NULL,
    album VARCHAR(255) DEFAULT '' NOT NULL,
    name VARCHAR(255) DEFAULT '' NOT NULL,
    PRIMARY KEY (id),
    KEY stuff (sharename, artist, album, name)
) TYPE=InnoDB;

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on July 29, 2004 2:01 PM.

Convention, Day One was the previous entry in this site.

Electoral Polls is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.