last fm cover script

Alles over software pakketten voor jouw station.

Moderator: admin6

smurfje
Berichten: 72
Lid geworden op: 07 feb 2011 18:44

Re: last fm cover script

Bericht door smurfje »

Wil je deze code van die wrapper misschien delen?
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Code: Selecteer alles

<?php

header("Refresh:30");

$station = "VUL HIER JE NAAM IN"; //ex: Radio Station
$sc_ip = "VUL HIER JE SHOUTCAST IP/HOST IN"; //ex: 6x.3x.18x.14x
$sc_port = "VUL HIER JE SHOUTCAST POORT IN"; //ex: 8000
$sc_sID = "VUL HIER JE SHOUTCAST STREAM ID IN"; //ex: 1 (default=1)

function shoutcast_load($url){
    	curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	$response = curl_exec($ch);
    	curl_close($ch);
    	return $response;
}

$url = "http://$sc_ip:$sc_port/stats?type=xml&sid=$sc_sID";
$data = shoutcast_load($url);
$xml = simplexml_load_string($data);

$song = $xml -> SONGTITLE;

$singinfo = explode(" - ", $song);

$artiest = $singinfo[0];
$titel = $singinfo[1];

function albumart_load($artiest,$titel,$size="large") //small (64x64px), medium (126x126px), large (174x174px), extralarge (300x300px)
    { 
	$URL = "http://api.depubliekeomroep.nl/anp/albumart.php?artiest=".urlencode($artiest)."&titel=".urlencode($titel)."&size=".urlencode($size); 
        $c = curl_init(); 
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($c, CURLOPT_URL, $URL); 
        $contents = curl_exec($c); 
        curl_close($c);
	return $contents;
}

$result = albumart_load("$artiest","$titel");

//BEGIN SERVER STATUS CHECK

if ($xml -> STREAMSTATUS != 1) {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Station offline</b>\n";
print "<br><br>geen albumart gevonden\n";
print "</body>\n";
print "</html>\n";

} else {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Now playing: </b>".htmlspecialchars($song)."\n";
print "<br><br><img src=\"".$result ."\">\n";
print "</body>\n";
print "</html>\n";

}

?>
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Code: Selecteer alles

<?php

header("Refresh:30");

$station = "VUL HIER JE NAAM IN"; //ex: Radio Station
$sc_ip = "VUL HIER JE SHOUTCAST IP/HOST IN"; //ex: 6x.3x.18x.14x
$sc_port = "VUL HIER JE SHOUTCAST POORT IN"; //ex: 8000
$sc_sID = "VUL HIER JE SHOUTCAST STREAM ID IN"; //ex: 1 (default=1)

function shoutcast_load($url){
    	curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	$response = curl_exec($ch);
    	curl_close($ch);
    	return $response;
}

$url = "http://$sc_ip:$sc_port/stats?type=xml&sid=$sc_sID";
$data = shoutcast_load($url);
$xml = simplexml_load_string($data);

$song = $xml -> SONGTITLE;

$singinfo = explode(" - ", $song);

$artiest = $singinfo[0];
$titel = $singinfo[1];

function albumart_load($artiest,$titel,$size="large") //small (64x64px), medium (126x126px), large (174x174px), extralarge (300x300px)
    { 
	$URL = "http://api.depubliekeomroep.nl/anp/albumart.php?artiest=".urlencode($artiest)."&titel=".urlencode($titel)."&size=".urlencode($size); 
        $c = curl_init();
	curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds 
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($c, CURLOPT_URL, $URL); 
        $contents = curl_exec($c); 
        curl_close($c);
	return $contents;
}

$result = albumart_load("$artiest","$titel");

//BEGIN SERVER STATUS CHECK

if ($xml -> STREAMSTATUS != 1) {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Station offline</b>\n";
print "<br><br>geen albumart gevonden\n";
print "</body>\n";
print "</html>\n";

} else {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Now playing: </b>".htmlspecialchars($song)."\n";
print "<br><br><img src=\"".$result ."\">\n";
print "</body>\n";
print "</html>\n";

}

?>
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Onderste code is de juiste!
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Code: Selecteer alles

<?php

header("Refresh:30");

$station = "VUL HIER JE NAAM IN"; //ex: Radio Station
$sc_ip = "VUL HIER JE SHOUTCAST IP/HOST IN"; //ex: 6x.3x.18x.14x
$sc_port = "VUL HIER JE SHOUTCAST POORT IN"; //ex: 8000
$sc_sID = "VUL HIER JE SHOUTCAST STREAM ID IN"; //ex: 1 (default=1)

$sc_nocover = "https://upload.wikimedia.org/wikipedia/commons/b/b9/No_Cover.jpg";

function shoutcast_load($url){
    	curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	$response = curl_exec($ch);
    	curl_close($ch);
    	return $response;
}

$url = "http://$sc_ip:$sc_port/stats?type=xml&sid=$sc_sID";
$data = shoutcast_load($url);
$xml = simplexml_load_string($data);

$song = $xml -> SONGTITLE;

$singinfo = explode(" - ", $song);

$artiest = $singinfo[0];
$titel = $singinfo[1];

function albumart_load($artiest,$titel,$size="extralarge") // small (64x64px), medium (126x126px), large (174x174px), extralarge (300x300px)
    { 
	$URL = "http://api.depubliekeomroep.nl/anp/albumart.php?artiest=".urlencode($artiest)."&titel=".urlencode($titel)."&size=".urlencode($size); 
        $c = curl_init(); 
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($c, CURLOPT_URL, $URL);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds 
        $contents = curl_exec($c); 
        curl_close($c);
	return $contents;
}

$cover = albumart_load("$artiest","$titel");
 
if ($cover == "") {
$cover = "$sc_nocover"; }

//BEGIN SERVER STATUS CHECK

if ($xml -> STREAMSTATUS != 1) {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Station offline</b>\n";
print "<br/><br/><img width=\"300\" height=\"300\" src=\"".$sc_nocover."\">\n";
print "</body>\n";
print "</html>";

} else {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Now playing: </b>".htmlspecialchars($song)."\n";
print "<br/><br/><img width=\"300\" height=\"300\" src=\"".$cover."\">\n";
print "</body>\n";
print "</html>";

}

?>
Laatst gewijzigd door corsschip op 22 nov 2019 04:39, 1 keer totaal gewijzigd.
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Nu met No Cover fallback!
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Code: Selecteer alles

<?php

header("Refresh:30");

$station = "VUL HIER JE NAAM IN"; //ex: Radio Station
$sc_ip = "VUL HIER JE SHOUTCAST IP/HOST IN"; //ex: 6x.3x.18x.14x
$sc_port = "VUL HIER JE SHOUTCAST POORT IN"; //ex: 8000
$sc_sID = "VUL HIER JE SHOUTCAST STREAM ID IN"; //ex: 1 (default=1)

$sc_nocover = "https://upload.wikimedia.org/wikipedia/commons/b/b9/No_Cover.jpg";

function shoutcast_load($url){
    	curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	$response = curl_exec($ch);
    	curl_close($ch);
    	return $response;
}

$url = "http://$sc_ip:$sc_port/stats?type=xml&sid=$sc_sID";
$data = shoutcast_load($url);
$xml = simplexml_load_string($data);

$song = $xml -> SONGTITLE;

$singinfo = explode(" - ", $song);

$artiest = $singinfo[0];
$titel = $singinfo[1];

function albumart_load($artiest,$titel,$size="extralarge") // small (64x64px), medium (126x126px), large (174x174px), extralarge (300x300px)
    { 
	$URL = "http://api.depubliekeomroep.nl/anp/albumart.php?artiest=".urlencode($artiest)."&titel=".urlencode($titel)."&size=".urlencode($size); 
        $c = curl_init(); 
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($c, CURLOPT_URL, $URL);
	curl_setopt($c, CURLOPT_TIMEOUT, 10); //timeout in seconds 
        $contents = curl_exec($c); 
        curl_close($c);
	return $contents;
}

$cover = albumart_load("$artiest","$titel");
 
if ($cover == "") {
$cover = "$sc_nocover"; }

//BEGIN SERVER STATUS CHECK

if ($xml -> STREAMSTATUS != 1) {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body style=\"background-color:grey\">\n";
print "<img width=\"300\" height=\"300\" src=\"".$sc_nocover."\"><br><br>\n";
print "<font face=\"verdana\" color=\"#ffffff\"><b>Station offline</b></font><br><br>\n";
print "</body>\n";
print "</html>";

} else {

print "<!DOCTYPE html>\n";
print "<html lang=\"en\">\n";
print "<head>\n";
print "<title>".$station."</title>\n";
print "</head>\n";
print "<body style=\"background-color:grey\">\n";
print "<img width=\"300\" height=\"300\" src=\"".$cover."\"><br><br>\n";
print "<font face=\"verdana\" color=\"#ffffff\"><b>".htmlspecialchars($song)."</b></font><br><br>\n";
print "</body>\n";
print "</html>";

}

?>
Gebruikersavatar
corsschip
Berichten: 25
Lid geworden op: 17 jan 2019 22:58

Re: last fm cover script

Bericht door corsschip »

Kleine verandering aangebracht en error opgelost.
Hier een voorbeeld:

http://www.startlinken.nl/TEST/shoutcast.php
DannyTeunissen
Berichten: 71
Lid geworden op: 16 jan 2020 21:17

Re: last fm cover script

Bericht door DannyTeunissen »

Mooi script.. zou het graag willen gebruiken. Kan je me vertellen met welke versie van shoutcast dit gedaan is ? En wat is shoutcast stream ID ?

Sorry voor de beginners vragen doe dit voor het eerst.
Plaats reactie