Parsing a Playlist.com playlist with PHP

PHP Add comments

burningwriter needed a quick way to download all the songs in a Playlist.com playlist (formerly called Project Playlist), so I wrote this quick script to parse the playlist files as links that DownThemAll can read.

To use it, download a playlist from Playlist.com.
You do this by clicking the “Export Playlist To Windows Media Player” link on the right side of the site. If it doesn’t prompt you to download a file, right click the link and select Save As.

Then upload the asx.wvx file here: samutz.com/playlist
The script will generate links from the playlist. You can then download them individually or use something like DownThemAll to get them all at once.

Source and more technical info after the jump.

Asx.wvx is basically just an xml file that Windows Media Player can read to play the songs in the playlist.

You can load it in to PHP with SimpleXML.

Here’s the source code for the page I made at samutz.com/playlist

<form action="index.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>

<?php
if (isset($_FILES['file']) && $_FILES['file']['error']==0) {
	$xml = simplexml_load_file($_FILES['file']['tmp_name']);
	foreach ($xml->entry as $entry) {
		$attr = $entry->ref->attributes();
		echo '<a href="'.$attr['href'].'">'.$entry->title.' by '.$entry->author.'</a><br/>';
	}
} else {
	echo 'Upload asx.wvx above.';
}
?>

4 Responses to “Parsing a Playlist.com playlist with PHP”

  1. S.Some Says:

    something is jamming the script from running … line 11

    complete error:
    Warning: simplexml_load_file() [function.simplexml-load-file]: /tmp/phprtWyOW:14: parser error : xmlParseEntityRef: no name in /home/samutz/public_html/playlist/index.php on line 11

    Warning: simplexml_load_file() [function.simplexml-load-file]: ttp://www.mystoandpizzi.com/downloads/Britney%20Spears%20-%20Circus%20(Mysto%20& in /home/samutz/public_html/playlist/index.php on line 11

    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/samutz/public_html/playlist/index.php on line 11

    Warning: simplexml_load_file() [function.simplexml-load-file]: /tmp/phprtWyOW:218: parser error : xmlParseEntityRef: no name in /home/samutz/public_html/playlist/index.php on line 11

    Warning: simplexml_load_file() [function.simplexml-load-file]: /www.mystoandpizzi.com/downloads/Kanye%20West%20-%20Love%20Lockdown%20(Mysto%20& in /home/samutz/public_html/playlist/index.php on line 11

    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/samutz/public_html/playlist/index.php on line 11

    Warning: Invalid argument supplied for foreach() in /home/samutz/public_html/playlist/index.php on line 13

  2. S.Some Says:

    Here’s a weird way .. but it works …
    1- Start the same … right click the ‘Export Playlist..’ and save the asx file anywhere.
    2 – open a text editor that will give you the html tags you need for a ‘new html page’ (like editplus.com)
    3 – open the asx file > copy/paste the complete text between the and tags
    4 – use find/replace two times
    4a – find <ref href=" replace with replace with .mp3″>MP3 Song Link
    5 – save the file and open it in your firefox browser that has DownThemAll plugin installed & there you go…
    .. ss sez: live free or shut up and ride

    4 -

  3. S.Some Says:

    these two lines display wrong in the page above … here they are re-typed::
    4 – use find/replace two times
    4a – find ” <ref href=" " replace with " ” replace with ” .mp3″>MP3 Song Link

  4. S.Some Says:

    Sorry for the messy commentsthis site renders html tags from within commentstry this:
    4 – use find/replace two times
    4a – find <ref href= replace with <a href=
    4b – find .mp3″/> replace with .mp3″>MP3 Song Link</a><br />

Leave a Reply

WP Theme & Icons by N.Design Studio
Web Site Terms and Conditions of Use Entries RSS Comments RSS Log in