I'm stealing The MOMI, baby. Four down, three thousand four hundred and twelve to go.
Update: The MOMI is smart. They have per connection bandwidth restrictions (it seems) that only allow you to download at about twice as fast as would be required to actually stream the MP3. This means it will take a LONG time to finish. Additionally, PHP was running out of memory (even though I was using fputs() and fgets() it somehow decided that it needed to place the ENTIRE file in memory…. bug?) so I converted it to use wget to grab the files.
Update Again: FUCK! The MOMI is WAY too smart. It caught me, and now, regardless of what file I'm trying to get, it gives me "All about the Pentiums". Damn it.
Update Again: I think they may be doing User Agent detection, therefore not being as smart as I initially thought. But I could be wrong. It's still letting me stream the files from XMMS, so now I have to see if I can get wget to allow me to supply my own user agent. When they decide to punish you, all the real MP3s redirect you to a directory called "ring_of_fire" on their site where there are 4 files. Fleetwood Mac's "Rhiannon", "All about the Pentiums", The laughing part of "Wipeout" (it just says "Hahahahahahahahahah Wipeout"), and a song titled "Valentine" which I am not sure what it is… but it is awful. Haha… and the Fleetwood Mac song turns out to be "Pentiums" misnamed.
Last Update… I hope: It looks like spoofing the User Agent to be "XMMS/1.2.5″ works. We'll see if it kills me soon.
#!/usr/bin/php4 -q
<?# Directory full of the MOMI playlists.
$plsdir = "/home/revjim/themomi";
$savedir = "/mnt/share/mp3s/themomi";#open our PLS dir
$dh = opendir($plsdir);#Get the filenames one by one
while($colfilename = readdir($dh)) {
# We don't need "." and ".."… Skip them
# Also skip anything that isn't a .m3uif(($colfilename == "." OR $colfilename == "..") AND (substr($colfilename,-3,3) != "m3u")) {
next;
}# Take off the extension for a prettier name
$colname = substr($colfilename,0,-4);# Use the prettier name in the save path
$colpath = $savedir . "/" . $colname;# Get the items from the M3U file
$mp3list = file($plsdir . "/" . $colfilename);foreach($mp3list as $mp3item) {
# Take off the newline at the end of the line
$mp3item = trim($mp3item);# Skip anything that looks like a comment
if (substr($mp3item,0,1) != "#") {# Break up the filename to get the last portion
$tmp = explode("/",$mp3item);
$file = $tmp[count($tmp) - 1];# Let me know what your doing.
print $mp3item . " -> " . $colpath . "/" . $file . "\n";# Make the collection directory, if it doesn't already exist
if (! file_exists($colpath) ) {
print "Making Directory $colpath.\n";
mkdir($colpath,0777);
}/* PHP USES TOO MUCH MEMORY THIS WAY
# Open the local file
$pfp = fopen($colpath . "/" . $file, "w");# Open the remote file
$gfp = fopen($mp3item,"r");# Get it and put it until we run out of bytes
while(!feof($gfp)) {
fputs($pfp,fgets($gfp,2048));
}# Close the doors
fclose($gfp);
fclose($pfp);
}
*/#PHP keep running out of mempry… try with wget instead
system("wget " . escapeshellarg($mp3item) . " -U Xmms/1.2.5 -O " . escapeshellarg($colpath . "/" . $file));print "\n";
}}
}
# All done, close up.
closedir($dh);
?>











