View Full Version : Radio Stats Album Artwork
:Edzy
14-02-2007, 05:44 PM
Would It Be Possible To Modify The GMTT Radio Stats (the most used ones) So They Display Album Artwork Of The Song
If anyone could provide me with the code i would highly apreciate it
Regards,
Ed
+REP TO ALL WHO HELP.
Edited by Lµke (Forum Moderator): Thread Moved From Website Designing. Please post in the correct section next time, Thanks :).
On topic-I dunno
Off topic-Hey ed how you doing?
:Edzy
14-02-2007, 05:57 PM
On topic: erm yer it might be easy <-- Load of crap
Off topic: hey ozness i'm good ta u? aint spoken in ages but i still have u on msn :D
Luckyrare
14-02-2007, 06:08 PM
Yes it could be done, you could use last.fm to get the images... Quite easy really
:Edzy
14-02-2007, 06:12 PM
ok so how would i go about tht?
What you mean by album artwork?
Robbie
14-02-2007, 07:08 PM
Pictures of the album the song is on
Luckyrare
14-02-2007, 07:23 PM
Well this is how you would do it... (Would be a picture of the artists)
-> Get artist name
-> Get files contents of the artist - http://www.last.fm/music/artist
You would have to replace a space with a "+"
eg) http://www.last.fm/music/U2
-> Get the content of
<div class="imgHolder"></div>using eregi
Good luck ;)
Dentafrice1
14-02-2007, 11:52 PM
http://imager.ffwbmarion.com/album/U2.png
I cant make it where it does bands like: Boys Like Girls.. as it adds the %20's or something? :S
http://imager.ffwbmarion.com/album/U2.png
I cant make it where it does bands like: Boys Like Girls.. as it adds the %20's or something? :S
urldecode();
Dentafrice1
15-02-2007, 03:03 AM
Warning: file_get_contents(http://www.last.fm/music/Boys Like Girls) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/skylight/public_html/testalbum.php on line 5
:Edzy
16-02-2007, 10:26 AM
Well this is how you would do it... (Would be a picture of the artists)
-> Get artist name
-> Get files contents of the artist - http://www.last.fm/music/artist
You would have to replace a space with a "+"
eg) http://www.last.fm/music/U2
-> Get the content of
<div class="imgHolder"></div>using eregi
Good luck ;)
so i have to add each band/artist manually
isnt there a simpler code to just stick into the stats so it grabs it from the sound file playing because SAM can read it :S
timROGERS
16-02-2007, 10:58 AM
Just get the artist out of the Now Playing (try exploding by " - " and then using $variable[0] to get the artist name) and then just put that into the URL you want to query.
Dentafrice1
16-02-2007, 12:41 PM
i have mine working but it always adds %20's and never works. And with URL Decode it messes up
I have this working with spaces etc.
http://thomas.uk.to/artist.php?artist=The Fratellis (http://thomas.uk.to/artist.php?artist=The%20Fratellis)
<?php
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="imgHolder">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
echo '<img src="' . $image . '">';
?>Doesnt make the page an image using GD though.
I have also made one to recieve the artists latest album.
http://thomas.uk.to/album.php?artist=The Fratellis (http://thomas.uk.to/album.php?artist=The%20Fratellis)
<?php
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/+albums?order=date";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="cover">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
echo '<img src="' . $image . '">';
?>
Dentafrice1
16-02-2007, 04:39 PM
http://imager.ffwbmarion.com/album/Kiss.png
http://imager.ffwbmarion.com/album/Boys%20Like%20girls.png
<?php
header("Content-Type: image/gif");
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="imgHolder">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
$image2 = imagecreatefromjpeg($image);
imagegif($image2);
?>
There you go :)
Wish last.fm wasnt so slow though
Dentafrice1
16-02-2007, 04:45 PM
Yea but it gets used alot so it takes a while.
=[
How can I explode: Dawn of the Dude - Set Us Free
into just Dawn of the Dude?
timROGERS
16-02-2007, 05:02 PM
<?php
$song_data = "Dawn of the Dude - Set Us Free";
$song_data_exploded = explode(" - ", $song_data);
?>
<?php
$song_data = "Dawn of the Dude - Set Us Free";
$song_data_exploded = explode(" - ", $song_data);
?>
Then you could echo is out using
echo $song_data_exploded[0];
timROGERS
16-02-2007, 05:04 PM
Then you could echo is out using
echo $song_data_exploded[0];
I would have said it, but I would have thought he could have worked it out :P
Yeah i just said it for no reason...
Or maybe to help other people who want to do this? Maybe
Dentafrice1
16-02-2007, 05:10 PM
Thanks you two +REP ;)
Im leaning alot more about exploding things this way and more ways I can use it in my programs.
Kevin
Yeah I only learnt about properly using explode when coding habbo imager stuff. I understand it alot now.
Dentafrice1
16-02-2007, 05:19 PM
Im starting to learn how to search through divs etc thanks to you thomas :)
I learned GD through the imager things too.. and now im pretty dang good at it :P
timROGERS
16-02-2007, 05:22 PM
I've made it easier now, this function is for anyone who needs it. To use it just save it as albumart.php and then put the following into your page:
<?php
include("albumart.php");
getAlbumArt($current_playing_song);
?>
By the way, it explodes it for you, so just put it directly from your shoutcast stats script. Here is albumart.php:
<?php
function getAlbumArt($now_playing) {
$artist_name = explode(" - ", $now_playing);
$artist_name = str_replace(" ", "+", $artist_name);
$url_to_query = "http://www.last.fm/music/" . $artist_name . "/";
$query = file_get_contents($url_to_query);
$album_art_start = explode('<div class="imgHolder">', $query);
$album_art_end = explode('</div>', $album_art_start[1]);
$album_art_html = trim($album_art_end[0]);
$image_url_start = explode('<img src="', $album_art_html);
$image_url_end = explode('" alt', $image_url_start[1]);
$image_url = trim($image_url_end[0]);
echo '<img src="' . $image_url . '" alt="' . $artist_name . '">';
}
?>
Nice little script +rep (dunno if my power will affect it)
Dentafrice1
16-02-2007, 05:27 PM
Nice script. I cant +rep again but I will soon ;)
Your better at functions and classes then I am :P
But if they dont want it to echo it out you could edit it to:
<?php
function getAlbumArt($now_playing) {
$artist_name = explode(" - ", $now_playing);
$artist_name = str_replace(" ", "+", $artist_name);
$url_to_query = "http://www.last.fm/music/" . $artist_name . "/";
$query = file_get_contents($url_to_query);
$album_art_start = explode('<div class="imgHolder">', $query);
$album_art_end = explode('</div>', $album_art_start[1]);
$album_art_html = trim($album_art_end[0]);
$image_url_start = explode('<img src="', $album_art_html);
$image_url_end = explode('" alt', $image_url_start[1]);
$image_url = trim($image_url_end[0]);
return $image_url;
}
?>
Then you would put
<?php
include('albumart.php');
$album = getAlbumArt("Artist Name - Song Name");
//Then you could echo it out whenever you wanted
echo '<img src="'.$album.'">';
//Or you could use it with GD etc
?>
timROGERS
16-02-2007, 05:36 PM
Nice implementation Thomas :)
Dentafrice1
16-02-2007, 05:36 PM
GD Would just be
<?php
header("Content-Type: image/gif");
include('albumart.php');
$album = getAlbumArt("Artist Name - Song Name");
$image = imagecreatefromjpeg($album);
imagegif($image);
?>
Change
header("Content-Type: image/gif");
the GIF to whatever file format you want
and change
imagegif($image)
change the gif to whatever file format you want.
So, does that help you Edzy?
Dentafrice1
16-02-2007, 07:35 PM
Im sure all of our posts helped him :P
:Edzy
17-02-2007, 09:59 AM
So, does that help you Edzy?
Does That Help Me?
That More Than Helps Me!
Thanks SO Much Guyzz!
:Edzy
17-02-2007, 01:13 PM
Edit: this is so irritating lolz sam 2 cant display the artist seperatly and not on stats either so it cant work unless you call the file
e.g the+ordinary+boys
but it still has a space and a dash after it so its a bit of a bugger but anyway
xD
Dentafrice1
17-02-2007, 03:23 PM
Whats the link to your stats and I can help you?
Don't worry about on sam 2 i can fix it if you post your entire stats.php or whatever you named it script ;)
Luckyrare
17-02-2007, 03:50 PM
How is it displayed? If its like "Songname - Artist" you could use explode()
:Edzy
17-02-2007, 07:05 PM
Okaiz
config_radio.php
<?php
$scdef = "Anyhabbo";
$scip = "66.225.228.179";
$scport = "8004";
$scpass = "NOT TELLING";
?>
radio_stats.php
<?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// ©2004-2005 Daniel Brown http://www.gmtt.co.uk
// Please refer to the readme file for use.
// ©2004-2005 Coleman Hamilton http://www.dj-coleman.com
// Coleman Hamilton added:
// Add-On MAXLISTNERS insead of the / 10 MAXLISTENERS which was set, and the BITRATE add-on.
// Online and Offline graphics, and add-on code.
// Better HTML Script.
// Do Not Try To Edit This Only Unless You Know What You're Doing!!!!!!!
include('config_radio.php');
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' is Offline';
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
################################################## ################################################## ##################
/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements
################################################## ################################################## ##################
################################################## ################################################## ##################
/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info
fclose($scfp);
}
//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
echo('
<html>
<head>
<body background="images/saysbg.gif">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="http://www.anyhabbo.com/habbozoo/css.css">
<title>'.$scdef.'</title>
</head>
<b>Current Presenter:</b> '.$servertitle.'<br \><b>Current Listeners:</b> '.$currentlisteners.' / '.$maxlisteners.'<br \><b>Current Song:</b> '.$song[0].'</font>   <br /><a href="radio_stats.php">[REFRESH]</a>
</body>
</html>');
}
if($streamstatus == "0")
{
//you may edit the html below, make sure to keep variable intact
echo'
<html>
<head>
<body background="images/saysbg.gif">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Radio Server Is Offline</title>
</head>
<font color="#6ABAF6">
<center>
<img src="images/offline.jpg"><br>
<a href="radio_stats.php">[REFRESH]</a></center>
</body>
</html>';
}
?>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
Dentafrice1
17-02-2007, 07:12 PM
<?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// ©2004-2005 Daniel Brown http://www.gmtt.co.uk
// Please refer to the readme file for use.
// ©2004-2005 Coleman Hamilton http://www.dj-coleman.com
// Coleman Hamilton added:
// Add-On MAXLISTNERS insead of the / 10 MAXLISTENERS which was set, and the BITRATE add-on.
// Online and Offline graphics, and add-on code.
// Better HTML Script.
// Do Not Try To Edit This Only Unless You Know What You're Doing!!!!!!!
include('config_radio.php');
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' is Offline';
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
################################################## ################################################## ##################
/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements
################################################## ################################################## ##################
################################################## ################################################## ##################
/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info
fclose($scfp);
}
//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
$name = explode(" - ", $song[0]);
$artist = $name[0];
$url = "http://www.ffwbmarion.com/album.php?artist=$artist";
$url = eregi_replace(" ", "+", $url);
$thing = file_get_contents($url);
echo("
<html>
<head>
<body background=\"images/saysbg.gif\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.anyhabbo.com/habbozoo/css.css\">
<title>'.$scdef.'</title>
</head>
<img src=$thing>
<b>Current Presenter:</b> '.$servertitle.'<br \><b>Current Listeners:</b> '.$currentlisteners.' / '.$maxlisteners.'<br \><b>Current Song:</b> '.$song[0].'</font>   <br /><a href=\"radio_stats.php\">[REFRESH]</a>
</body>
</html>");
}
if($streamstatus == "0")
{
//you may edit the html below, make sure to keep variable intact
echo'
<html>
<head>
<body background="images/saysbg.gif">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Radio Server Is Offline</title>
</head>
<font color="#6ABAF6">
<center>
<img src="images/offline.jpg"><br>
<a href="radio_stats.php">[REFRESH]</a></center>
</body>
</html>';
}
?>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
:Edzy
17-02-2007, 07:24 PM
Thanks sooooooo much
would u also be able to post your album.php
Dentafrice1
17-02-2007, 07:40 PM
Yea one sec.
<?php
header("Content-Type: image/gif");
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="imgHolder">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
echo $image;
?>
:Edzy
17-02-2007, 07:42 PM
TOP Bloke Ta!
Dentafrice1
17-02-2007, 07:46 PM
Glad I could help. If you need anything else reply ;)
Kevin
:Edzy
18-02-2007, 12:26 PM
Lol dragging this post on
Is there a way for it to show eg "noart.jpg" when a dj is using a custom $combine$ thing in sam or when last.fm doesnt have the artist instead of showing:
Warning: file_get_contents(http://www.last.fm/music/Ed//+My+Chemical+Romance/) [function.file-get-contents (http://anyhabbo.com/function.file-get-contents)]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/anyhabbo/public_html/albumart.php on line 10
>
timROGERS
18-02-2007, 12:49 PM
I think you can use "or", but you'll have to write it into the code yourself:
file_get_contents("artist") or echo "<img src='noart.jpg' />";
ScottDiamond
18-02-2007, 01:18 PM
Would else and echo not work?
Would else and echo not work?
http://tehwasher.co.uk/text/It should do, I think
:Edzy
18-02-2007, 05:23 PM
<?php
header("Content-Type: image/gif");
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
file_get_contents("artist") or echo "<img src='noart.jpg' />";
$image1start = explode('<div class="imgHolder">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
echo $image;
?>
Correct?
Dentafrice1
18-02-2007, 07:35 PM
I think you can use "or", but you'll have to write it into the code yourself:
file_get_contents("artist") or echo "<img src='noart.jpg' />";
Wouldnt it be
if(!file_get_contents($url)) {
echo "<img src='noart.jpg'>";
}
reindeer.
26-02-2007, 09:28 PM
Umm,
why have I got this?
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/teamstea/public_html/habbobuzz/imagestats.php on line 13
Warning: fsockopen() [function.fsockopen]: unable to connect to :0 (Unknown error) in /home/teamstea/public_html/habbobuzz/imagestats.php on line 13
is Offline
Line 13 is:
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
Dentafrice1
26-02-2007, 09:35 PM
Probably firewall.
reindeer.
26-02-2007, 09:43 PM
Uhm ok
Dentafrice1
26-02-2007, 09:46 PM
The firewall on your server cannot connect to it, or your servers down.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.