daily pastebin goal
70%
SHARE
TWEET

BBC radio streamer using mpc

pr4wn Apr 16th, 2015 22 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. # BBC radio stream media player.
  6. # Author: prawn [sean dot prawn at gmail dot com]
  7. # Released under GPL V2. <https://www.gnu.org/licenses/gpl-2.0.html>
  8. # Needs mpc.
  9.  
  10. my $version = "0.1";
  11. my %stations = qw(
  12.   r1 http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p
  13.   r1x http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1xtra_mf_p
  14.   r2 http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p
  15.   r3 http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio3_mf_p
  16.   r4 http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p
  17.   r4lw http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4lw_mf_p
  18.   r4x http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4extra_mf_p
  19.   r5l http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5live_mf_p
  20.   r5x http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5extra_mf_p
  21.   r6 http://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p
  22. );
  23.  
  24. sub help {
  25.  
  26.   print "Usage: $0 station\n\n";
  27.   print "Stations:\n";
  28.  
  29.   foreach my $key (sort ( keys %stations ) ) {
  30.  
  31.     print "\t$key\t$stations{$key}\n";
  32.  
  33.   }
  34.  
  35.   print "\nTo stop player, type mpc clear\n";
  36.  
  37. }
  38.  
  39. print $0 . " version $version\n";
  40.  
  41. if ( $#ARGV < 0 ) { help(); exit; }
  42.  
  43. if ( $stations{$ARGV[0]} ) {
  44.  
  45.     print "Playing radio stream $stations{$ARGV[0]}\n";
  46.     `mpc clear`;
  47.     `mpc add $stations{$ARGV[0]}`;
  48.     `mpc play`;
  49.     print "\nTo stop player, type mpc clear\n";
  50.  
  51. } else {
  52.  
  53.   help();
  54.  
  55. }
RAW Paste Data
Top