Skip to content

Instantly share code, notes, and snippets.

@sobi3ch
Created March 27, 2015 11:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobi3ch/fe4af2bcf8d34c3178c1 to your computer and use it in GitHub Desktop.
Save sobi3ch/fe4af2bcf8d34c3178c1 to your computer and use it in GitHub Desktop.
Polish radiostations from linux CLI / Polskie radiostacje z linii poleceń
<?php
define('INDENT', ' ');
// Radio list
$radiostations = [
'trojka' => 'mms://stream.polskieradio.pl/program3_wma10',
'dwojka' => 'mms://stream.polskieradio.pl/program2_wma10',
'jedynka' => 'mms://stream.polskieradio.pl/program1_wma10',
'luz' => 'http://radioluz.pwr.wroc.pl/listen.pls',
'pin' => 'http://www.radiopin.pl/shoutcast/radiopin128.m3u',
'tokfm' => 'http://www.radio.pionier.net.pl/stream.pls?radio=radiotok',
];
if (!isset($argv[1]) || empty($argv[1])) {
echo 'Usage: polon <radioname>'. PHP_EOL;
foreach (array_keys($radiostations) as $radioname) {
echo INDENT . $radioname . PHP_EOL;
}
} else {
$name = $argv[1];
if (array_key_exists($name, $radiostations)) {
echo INDENT . 'Playing: ' . $name . PHP_EOL;
$command = 'mplayer -quiet '. $radiostations[$name];
echo $command . PHP_EOL;
$output = shell_exec($command);
echo $output;
} else {
echo INDENT . "Sorry, couldn't find this radio station";
}
}
@sobi3ch
Copy link
Author

sobi3ch commented Mar 27, 2015

Usage: php polon.php list all stations
php polon.php <radiostation> runs radio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment