Skip to content

Instantly share code, notes, and snippets.

@Koenvh1
Created January 14, 2017 16:57
Show Gist options
  • Save Koenvh1/c2bf7c813a456f8b66c46c7ac891ace0 to your computer and use it in GitHub Desktop.
Save Koenvh1/c2bf7c813a456f8b66c46c7ac891ace0 to your computer and use it in GitHub Desktop.
Convert StreamTheWorld.com callsign to actual stream URL
<?php
/*
* Because the actual streaming URLs from StreamTheWorld.com stations change often,
* this script will dynamically redirect you to the stream URL.
*
* Do with it what you want :-)
* Koen (koenvh.nl)
*
* Usage: Provide a "sign" argument in your get request.
* This is the station's sign, which is the part after the slash without the (AAC)_SC part.
*
*/
if(isset($_GET["sign"])){
$ini = parse_ini_string(file_get_contents("http://provisioning.streamtheworld.com/pls/" . $_GET["sign"] . ".pls"));
//var_dump($ini);
$url = $ini["File1"];
if(filter_var($url, FILTER_VALIDATE_URL)){
header("Location: " . $url);
die();
} else {
echo "Invalid URL: " . $url;
}
} else {
echo "No sign";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment