Shoutcast auslesen + Bild?

Status
Für weitere Antworten geschlossen.

DJ_Thias

Benutzer
Hallo zusammen,

ich hoffe, bin hier richtig & zwar habe ich folgendes "Problem".
Meine Sendebilder werden momentan mit AIM ausgelesen.
Gibt es irgendwie eine Möglichkeit das mit der Genre oder Streamtitel zu machen? Ich habe schon gegooglet aber leider nicht viel gefunden.
Hier das Script was das AIM ausließt.

Code:
<?php 
/* 
Shoutcast stats through XML 
By Rayeh 
http://rayeh.sytes.net 
*/ 
$host = "xxx.xxx.xxx.xxx"; //Hostname, or ip address of server. IE blah.com or xx.xx.xx.xx 
$port = "8000"; //Port server is running on. IE 8000 
$password = "******"; //Password of server, can be normal or admin. Doesn't matter. 
//Configuration Finished 
//Runs each time an XML element starts 
function StartHandler(&$Parser, &$Elem, &$Attr) { 
global $Data, $CData; 
/* Start with empty CData array. */ 
$CData = array(); 
/* Put each attribute into the Data array. */ 
while ( list($Key, $Val) = each($Attr) ) { 
$Data["$Elem:$Key"] = trim($Val); 
// debug // echo "$Elem:$Key = " . $Data["$Elem:$Key"] . "\n"; 
} 
} 
//Runs each time XML character data is encountered 
function CharacterHandler(&$Parser, &$Line) { 
global $CData; 
/* 
* Place lines into an array because elements 
* can contain more than one line of data. 
*/ 
$CData[] = $Line; 
} 
//Runs each time an XML element ends 
function EndHandler(&$Parser, &$Elem) { 
global $Data, $CData, $listeners, $server, $song, $dj, $wee; 
//Mush all of the CData lines into a string and put it into the $Data array. 
$Data[$Elem] = trim( implode('', $CData) ); 
//echo "$Elem = " . $Data[$Elem] . "<br>\n"; 
switch ($Elem){ 
//for each case, we are putting some data into a variable. 
case 'AIM': 
$dj['AIM'] = $Data['AIM']; 
break; 
} 
} 
//open connection 
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); 
if (!$fp) { 
echo "Connection to server could not be established! <BR>"; 
} 
else { 
//request xml 
fputs($fp,"GET /admin.cgi?pass=".$password."&mode=viewxml&page=0 HTTP/1.0\nUser-Agent: Mozilla Compatible\n\n"); 
while(!feof($fp)) { 
//put xml into $Data 
$Contents .= fgets($fp, 1000); 
} 
} 
//close connection 
fclose($fp); 
$Contents = str_replace('HTTP/1.0 200 OK','', $Contents); 
$Contents = str_replace('Content-Type:text/xml','', $Contents); 
$Contents = str_replace("\n",'', $Contents); 
$Contents = str_replace("\r",'', $Contents); 
$Contents = preg_replace('/(&amp;|&)/i', '&amp;', $Contents); 
$Contents = preg_replace('/[^\x20-\x7E\x09\x0A\x0D]/', "\n", $Contents); 
$Data = array(); 
// Initialize the parser. 
$Parser = xml_parser_create('ISO-8859-1'); 
xml_set_element_handler($Parser, 'StartHandler', 'EndHandler'); 
xml_set_character_data_handler($Parser, 'CharacterHandler'); 
//Pass the content string to the parser. 
if (!xml_parse($Parser, $Contents)) { 
$Probs[] = "$URI$Sym\n Had problem parsing file:\n " 
. xml_error_string(xml_get_error_code($Parser)); 
} 
if (isset($Probs)) { 
echo implode("\n", $Probs); 
} 
//Output
$search = array('BASEFLOOR');
$replace = array('<IMG SRC="/Sendebilder/BASEFLOOR.png">;
echo str_replace($search, $replace, "
<tr><td></td><td>{$dj['AIM']}</td></tr>\n
");
 
?>

Ich hoffe, Ihr könnt mir weiterhelfen, Danke.

Gruß Thias
 
Status
Für weitere Antworten geschlossen.
Zurück
Oben