Reply
   
 Internode radio playlist 
 
 
  #1 (permalink)  
Old 13-08-2008, 10:25 AM
MacTalk Engineering Dept.

Group: Forum Leaders
Location: Sydney, Australia


Internode radio playlist

I wanted to listen to some Internode radio stations today but was annoyed that they serve each radio station up as a .pls with no Title in it, so you have to manually add each radio station.

So, I wrote this quick hacky script to download the entire list of radio stations and output a formatted .pls file that will add them all in one go.

Instructions

You will need to use the Terminal, here.

1. Copy this script to a file, called "downloadPlaylist.pl". Just cut and paste it into a textedit document, and save as plain text.

2. Mark the script as executable with chmod u+x downloadPlaylist.pl. You will need to cd to the directory that you saved the script.

3. Run the script with ./downloadPlaylist.pl. It will print some output while it's processing to show you it's progress.

4. It will have created an InternodeRadio.pls file in the same directory. You can now just drag this file into iTunes and it will create an entry for each of Internode's radio stations.

If Internode update their webpage, you should just rerun the script and it'll grab the latest stations. If they at some point change their HTML formatting, then it will break. But it was a 5 minute script.

Code:
#!/usr/bin/perl -w

#  This program is free software. It comes without any warranty, to
#  the extent permitted by applicable law. You can redistribute it
#  and/or modify it under the terms of the Do What The Fuck You Want
#  To Public License, Version 2, as published by Sam Hocevar. See
#  http://sam.zoy.org/wtfpl/COPYING for more details.

use strict;

my $html = `curl -sL http://www.internode.on.net/residential/entertainment/broadband_radio/`;

my $title = "";
my $url = "";
my $output = "";
my $count = 1;
my @list = split "\n", $html;

foreach (@list) {
	if (/warning\(\);\"><b>(.*)<\/b>/) {
		$title = $1;
	}

	if (/<strong><a href='(.*)'>Listen<\/a><\/strong>/ && $title ne "") {
		$url = `curl -sL $1`;
		$output .= "File$count=$url\nTitle=$title\n\n";
		print STDERR "$title - $url\n";
		$title = "";
		$count++;
	}
}

open OUTPUT, ">InternodeRadio.pls";
print OUTPUT "[playlist]\nNumberOfEntries=$count\n\n$output";
print OUTPUT "Version=2\n";
close OUTPUT;

print STDERR "Done!\n";
__________________
Mac Pro 2 x 4 core 2.8Ghz 16GB | Mac Book Pro 17" | iPhone 3G 16GB | 20" iMac 2 Core 2 Duo
Are you an Internode user? Download NodeQuota 1.0.7 - an Internode Usage Meter for Leopard!
chrome is offline
Profile CardPM
Go to the top of the page
Reply With Quote
 
Reply

Thread Tools

 
Similar Threads
 
Thread Thread Starter Forum Replies Last Post
Griffin Radio Shark 2 Review decryption Articles, How-to's and Reviews 22 29-06-2007 02:29 PM
iTunes Radio stream + Smart Playlists? Aa Mac OS X & All Software 0 11-10-2006 09:47 AM
More cars with iPod - radio will suffer Bart Smastard iPods, iPod Accessories & Other Digital Music Players 20 14-08-2006 07:27 PM
itunes - internode radio Galumay Mac OS X & All Software 4 24-02-2006 05:09 PM