dubtechradiopage/id.php

86 lines
2.7 KiB
PHP
Raw Normal View History

2016-12-12 07:30:34 +00:00
<?php
echo "id:;:";
2017-06-26 11:06:58 +00:00
// Shoutcast
function getID($radioip,$radioport,$postfix = "GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n")
2016-12-12 07:30:34 +00:00
{
$open = fsockopen($radioip,$radioport,$errno,$errstr,'.5');
if ($open) {
2017-06-26 11:06:58 +00:00
fputs($open,$postfix);
2016-12-12 07:30:34 +00:00
stream_set_timeout($open,'1');
$read = fread($open,255);
$exploded = explode(",",$read);
2017-06-26 11:06:58 +00:00
if($exploded[6] == '' || $exploded[6] == '</body></html>')
2016-12-12 07:30:34 +00:00
{ $text = 'streaming'; } else { $text = $exploded[6]; }
$id = str_replace("</body></html>","",$text);
} else { return false; }
fclose($open);
return $id;
}
2017-06-26 11:06:58 +00:00
// Icecast
// https://stackoverflow.com/a/17109654
function getMp3StreamTitle($streamingUrl, $interval, $offset = 0, $headers = true)
{
$needle = 'StreamTitle=';
$ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';
$opts = [
'http' => [
'method' => 'GET',
'header' => 'Icy-MetaData: 1',
'user_agent' => $ua
]
];
if (($headers = get_headers($streamingUrl)))
foreach ($headers as $h)
if (strpos(strtolower($h), 'icy-metaint') !== false && ($interval = explode(':', $h)[1]))
break;
$context = stream_context_create($opts);
if ($stream = fopen($streamingUrl, 'r', false, $context))
{
$buffer = stream_get_contents($stream, $interval, $offset);
fclose($stream);
if (strpos($buffer, $needle) !== false)
{
$title = explode($needle, $buffer)[1];
return substr($title, 1, strpos($title, ';') - 2);
}
else
return getMp3StreamTitle($streamingUrl, $interval, $offset + $interval, false);
}
else
throw new Exception("Unable to open stream [{$streamingUrl}]");
}
2016-12-12 07:30:34 +00:00
$radioip = "93.100.61.75";
$radioport = "8000";
echo getID($radioip,$radioport).":;:";
$radioip = "67.212.165.106";
$radioport = "8144";
echo getID($radioip,$radioport).":;:";
$radioip = "173.236.30.162";
$radioport = "8022";
echo getID($radioip,$radioport).":;:";
2017-06-26 11:06:58 +00:00
// // outdated:
// $radioip = "91.237.213.34";
// $radioport = "8008";
// echo getID($radioip,$radioport).":;:";
2016-12-12 07:30:34 +00:00
$radioip = "79.120.39.202";
$radioport = "9009";
2017-06-26 11:06:58 +00:00
echo getID($radioip,$radioport).":;:";
echo getMp3StreamTitle('http://audio-online.net:8015/live', 19200).":;:";
echo getMp3StreamTitle('http://prem2.di.fm/dubtechno_hi?95f925a23d7093d9f7156fc5', 19200).":;:";
$radioip = "136.243.16.19";
$radioport = "8000";
$postfix = "GET /7.html?sid=3 HTTP/1.1\nUser-Agent:Mozilla\n\n";
echo getID($radioip,$radioport,$postfix).":;:";
2016-12-12 07:30:34 +00:00
?>