#!/usr/bin/perl # fetchrmp.pl - a quick-n-dirty script for parsing EMusic RMP data and # fetching entire albums. Requires an EMusic.com subscription. :-) # AUTHOR: Doran Barton # VERSION 0.9 # Copyright (c) 2002 Doran Barton. All rights reserved. # This program is free software; you can distribute it and/or modify it # under the same terms as Perl itself. $VERSION = 0.9; use XML::EasyOBJ; use LWP::Simple; use Getopt::Long; Getopt::Long::config("no_ignore_case"); my $error = &GetOptions('help','destdir:s', 'rmpfile:s' ); if($opt_help) { exit _usage(); } if(!$opt_rmpfile) { print STDERR "ERROR: An RMP data file is required (with the --rmpfile parameter)\n"; exit _usage(); } if(!$opt_destdir) { $opt_destdir = "."; } my $doc = new XML::EasyOBJ($opt_rmpfile); my $server = $doc->SERVER(0)->NETNAME(0)->getString; my @elements = $doc->TRACKLIST(0)->TRACK; my $track_num = 1; foreach my $track (@elements) { my $url = sprintf("http://%s/%s/%s", $server, $track->TRACKID->getString, $track->FILENAME->getString); print STDERR "Getting ", $track->FILENAME->getString, "... "; my $rv = getstore($url, $track->FILENAME->getString); if($rv == 200) { print STDERR "OK\n"; } else { print STDERR "FAILED\n"; } } sub _usage { print STDERR "This is $0 version $VERSION\n", "Usage: $0 --help \n", " or: $0 [--destdir DIR] --rmpfile FILE\n\n", "Copyright (c) 2002 Doran Barton. All rights reserved.\n", "This program is free software; you can distribute it and/or modify it\n", "under the same terms as Perl itself.\n"; return 1; }