44 lines
791 B
PHP
44 lines
791 B
PHP
<?php
|
|
|
|
// urls needed
|
|
$apiurl = "your APi song url";
|
|
$encoderurl = "http://ipofaudiocompanion:port/api/setDLS?dls=";
|
|
|
|
// your DLS
|
|
|
|
$file = '/export/dls.txt';
|
|
|
|
while (true) {
|
|
|
|
|
|
$newText = file_get_contents($apiurl);
|
|
|
|
if ($newText === false) {
|
|
sleep(10);
|
|
continue;
|
|
}
|
|
|
|
|
|
$oldText = file_exists($file) ? file_get_contents($file) : '';
|
|
|
|
// send on change
|
|
|
|
if ($newText !== $oldText) {
|
|
|
|
|
|
$tmp = '/export/dls.tmp';
|
|
file_put_contents($tmp, $newText, LOCK_EX);
|
|
rename($tmp, $file);
|
|
|
|
$currentData = file_get_contents($file);
|
|
$url = $encoderurl . urlencode($currentData);
|
|
$response = file_get_contents($url);
|
|
// echo $response;
|
|
// will be: default coder ok
|
|
|
|
}
|
|
|
|
sleep(10);
|
|
}
|
|
?>
|