#!/usr/bin/perl -w # iplay.pl - by dual # # Plays streaming audio from the # command line ################################ use strict; my $module = "Mac::iTunes"; eval "use $module"; # Declare my $player = '/usr/bin/audacious2'; my ($os, $url); my %streams = ( bass => 'http://www.bassdrive.com/v2/streams/BassDrive.pls', chil => 'http://www.di.fm/mp3/chillout.pls', difm => 'http://www.di.fm/mp3/trance.pls', lnge => 'http://www.lounge-radio.com/listen128.m3u', rant => 'http://www.rantmedia.ca/industrial/rr-industrial128.pls', talk => 'http://www.rantmedia.ca/talk/rr-talk128.pls' ); # Get and check arg usage() unless defined(my $arg = shift); usage() unless $arg =~ /^(bass|chil|difm|lnge|rant|talk)$/; # Provide assistance sub usage { print "iplay.pl - Plays streaming audio from the command line Usage: perl iplay.pl bass - BassDrive.com chil - DI.fm Chillout difm - DI.fm Trance lnge - lounge-radio.com rant - RantRadio Industrial talk - RantRadio Talk "; exit; } # Determine OS if (`uname` =~ /Darwin/) { $os = 1 }; # Determine URL foreach my $key (keys %streams) { $url = $streams{$key} if $arg =~ /$key/; } # Play stream if ($os) { my $controller = Mac::iTunes->controller; $controller->open_url($url); } else { system("$player $url 2>/dev/null &"); }