Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Thursday July 29, 2004
04:01 PM

Totally Stealing Your Music at OSCON

[ #20137 ]

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;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.