Stories
Slash Boxes
Comments
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 ]

rjbs (4671)

rjbs
  (email not shown publicly)
http://rjbs.manxome.org/
AOL IM: RicardoJBSignes (Add Buddy, Send Message)
Yahoo! ID: RicardoSignes (Add User, Send Message)

I'm a Perl coder living in Bethlehem, PA and working Philadelphia. I'm a philosopher and theologan by training, but I was shocked to learn upon my graduation that these skills don't have many associated careers. Now I write code.

Journal of rjbs (4671)

Monday April 21, 2008
11:11 PM

muxtape.com, itunes, perl, and making mixtapes

[ #36210 ]

muxtape.com is a site where you can build mix tapes by uploading mp3 files. You can find other people's uploads and listen to them. It's the flea market tape swape of 2008. I like it.

A lot of people seem to be using it (I think) like a very, very high-latency radio station. Once in a while they upload a new song, bumping an old one. That's cool, but it's hardly a mix tape. I'd rather put together a collection of songs that play well together, then replace my whole tape with those.

The uploading interface requires that I delete and upload tracks one at a time. It also wants them in reverse order, since new tracks get the first position in the tape. Blech!

What I really want is to build a mix in iTunes, where I can drag things around, preview, and re-think selections. Then, I want to upload that whole playlist at once. I wrote a program to do that. Its source is listed below. The muxtape.com API isn't published or clearly-defined, so who knows how long this will work.

My new muxtape, the first I uploaded with mux-up, is now online.

use strict;
use warnings;

use WWW::Mechanize;
use Mac::Glue qw(:glue);

my $title = $ARGV[0];

my $iTunes = Mac::Glue->new('iTunes');

my $playlist = $iTunes->obj(
  playlist => whose(name => equals => $title)
);

my @tracks = @{ $playlist->obj('tracks')->get || [] };
die "couldn't find tracks in playlist <$title>" unless @tracks;

die "too many tracks" if @tracks > 12;

for (@tracks) {
  die "track too large" if $_->prop('size')->get > 10_000_000;
}

my $mech = WWW::Mechanize->new;

$mech->get('http://muxtape.com/login');

$mech->submit _form(
  with_fields => {
    name => 'USERNAME',
    pass => 'PASSWORD',
  },
);

$mech->get('http://muxtape.com/organize');

my @ids = $mech->content =~ m{li id="(song[0-9a-f]{32})"}g;

for my $id (@ids) {
  $id =~ s/^song//;
  print "deleting $id\n";

  $mech->post(
    'http://muxtape.com/organize/ajax',
    Content => "command=delete&args=$id",
  );
}

for my $track (reverse @tracks) {
  $mech->get('http://muxtape.com/upload');
  my $path = $track->prop('location')->get;
  print "uploading $path\n";
  $mech->submit_form(with_fields => { file => $path });
}

my @month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @lt    = localtime;
my $date  = "$month[ $lt[4] ] $lt[3]";

$title =~ s/.+: //;
$mech->post(
  'http://muxtape.com/settings/ajax',
  Content => qq{command=bannercaption&args="none"&banner=$date: $title},
);

print $mech->content;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • FWIW, my muxtape [muxtape.com] is very specifically sequenced to have decent segues between songs and to have a flow to it.

    My annoyance with muxtape is that people seem to try to put up what they see as the weirdest, most eclectic spread of tunes available, to show just how hip they are. "Dude, I like Bjork and Slayer and the Archies! Aren't I cool?!"

    --

    --
    xoa

    • One feature that could help fight the "this is a queue, not a playlist" would be to have snapshots. That is, save the listing of your tape before replacing it, so people can see past mixes you've produced -- rather than slowly mutate one list into another.

      Of course, that would only help if people then cared.
      --
      rjbs