dubtechradiopage/id.php

136 lines
4.1 KiB
PHP
Raw Normal View History

2016-12-12 07:30:34 +00:00
<?php
2017-06-26 11:06:58 +00:00
// Shoutcast
2018-05-17 09:30:49 +00:00
function getIDshout($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) {
2018-05-17 09:30:49 +00:00
fputs($open,$postfix);
stream_set_timeout($open,'1');
$read = fread($open,255);
$exploded = explode(",",$read);
if ($exploded[6] == '' || $exploded[6] == '</body></html>') {
2022-02-21 20:11:18 +00:00
$text = 'streaming'; } else { $text = $exploded[6]; }
2018-05-17 09:30:49 +00:00
$id = str_replace("</body></html>","",$text);
2016-12-12 07:30:34 +00:00
} else { return false; }
fclose($open);
return $id;
2018-05-17 09:30:49 +00:00
}
2017-06-26 11:06:58 +00:00
// Icecast
// https://stackoverflow.com/a/17109654
2018-05-17 09:30:49 +00:00
function getIDice($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}]");
}
2022-02-21 20:11:18 +00:00
// Anima Amoris
function getIDanima($amoris) {
2022-07-17 13:56:28 +00:00
$url = "http://amoris.sknt.ru/".$amoris."/stats.json";
2022-02-21 20:11:18 +00:00
$headers = array('User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
curl_close($ch);
$data = json_decode($data, true);
if (!empty($data)) $data = $data["songtitle"];
if (substr($data, -7) == "sknt.ru") $data = stristr($data, " * anima.sknt.ru", true);
return $data;
}
2016-12-12 07:30:34 +00:00
2021-01-16 16:17:34 +00:00
// first
2018-05-17 09:30:49 +00:00
echo "id:;:";
2021-01-16 16:17:34 +00:00
try {
2022-07-17 13:56:28 +00:00
echo getIDanima("dubtechno"); // Anima Amoris [DubTech]
2021-01-16 16:17:34 +00:00
} catch (Exception $exfirst) {
echo "unavailable";
}
// second
2018-05-17 09:30:49 +00:00
echo ":;:";
2019-08-02 13:31:09 +00:00
try {
2022-07-17 13:56:28 +00:00
echo getIDanima("dubtechnomix"); // Anima Amoris [DubTech Mix]
2021-01-16 16:17:34 +00:00
} catch (Exception $exsecond) {
2019-08-02 13:31:09 +00:00
echo "unavailable";
}
2021-01-16 16:17:34 +00:00
// third
2018-05-17 09:30:49 +00:00
echo ":;:";
2021-01-16 16:17:34 +00:00
try {
echo getIDshout("79.120.39.202","9009"); // Radio Caprice - Dub Techno
} catch (Exception $exthird) {
echo "unavailable";
}
// fourth
2018-05-17 09:30:49 +00:00
echo ":;:";
2021-01-16 16:17:34 +00:00
try {
echo getIDice("http://185.61.124.104:8066/live", 19200); // Loca FM Dub Techno
} catch (Exception $exfourth) {
echo "unavailable";
}
// fifth
2018-05-17 09:30:49 +00:00
echo ":;:";
2021-01-16 16:17:34 +00:00
try {
2022-02-21 20:11:18 +00:00
$fifthIDice = getIDice("http://94.130.113.214:8000/dubtechno", 19200); // Schizoid Dub Techno
if (bin2hex($fifthIDice) == "fffe66202d20fffe52") echo "online streaming";
else echo $fifthIDice;
2021-01-16 16:17:34 +00:00
} catch (Exception $exfifth) {
echo "unavailable";
}
// sixth
2018-05-17 09:30:49 +00:00
echo ":;:";
2019-08-02 13:31:09 +00:00
try {
2021-12-21 09:56:34 +00:00
echo getIDice("http://78.47.31.164:8002/dub", 19200); // MABU Beatz Dub Techno
2021-01-16 16:17:34 +00:00
} catch (Exception $exsixth) {
2019-08-02 13:31:09 +00:00
echo "unavailable";
}
2021-01-16 16:17:34 +00:00
// seventh
2018-05-17 09:30:49 +00:00
echo ":;:";
2021-01-16 16:17:34 +00:00
try {
2021-12-21 09:56:34 +00:00
echo getIDice("http://195.133.48.93:8000/MixCult_96kbps", 19200); // MixCult Deep Techno Radio
2021-01-16 16:17:34 +00:00
} catch (Exception $exseventh) {
echo "unavailable";
}
// eighth
echo ":;:";
try {
2021-12-21 09:56:34 +00:00
echo getIDice("https://c2.radioboss.fm:18382/stream", 19200); // dubte.ch
} catch (Exception $exeighth) {
2021-01-16 16:17:34 +00:00
echo "unavailable";
}
// ninth
echo ":;:";
try {
2021-12-21 09:56:34 +00:00
echo getIDice("http://prem2.di.fm:80/dubtechno_hi?266a3dc03aaa30a0807d9062", 19200); // Digitally Imported Dub Techno
2021-01-16 16:17:34 +00:00
} catch (Exception $exninth) {
echo "unavailable";
}
// tenth
echo ":;:";
try {
2022-07-17 13:56:28 +00:00
echo getIDanima("minimal"); // Anima Amoris [MinimalDeepTech]
2021-01-16 16:17:34 +00:00
} catch (Exception $extenth) {
echo "unavailable";
}
2018-05-17 09:30:49 +00:00
echo ":;:";
2021-01-16 16:17:34 +00:00
?>