last songs played

Discuss Shoutcast streaming here, any issues, advice or tips are welcome
Forum rules
Please don't use the forums to report outages, particularly if you are a FreeStreamHosting.org user.

last songs played

Postby prideplay » Wed 20th Jan, 2010 6:41 am

Hiya
I've noticed that the only way listernes can see the 10 last songs played are on a page where there's also a logon and other things.
Is it possible to get ONLY the 10 last songs played?
prideplay
 
Posts: 3
Joined: Thu 14th Jan, 2010 6:38 am

Re: last songs played

Postby Ferik » Thu 21st Jan, 2010 2:26 pm

PHP Shoutcast Class with example :D http://devshed.excudo.net/scripts/php/s ... cast+class

Download the Shoutcast class and try this php script.

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Shoutcast Test Page</title>
<style type="text/css">
.songOverview {
   width:30%;
   border:1px solid black;
   background-color: #EEE;
   }
.songOverview td {
   padding: 1px 10px 1px 1px;
   }
</style>
</head>
<body>
<?php

require_once ('shoutcast_class.php');

///YOUR RADIO CONFIGURATION IP & PORT///
$ip   = "stream_address_here";
$port = "port_here";
////////////////////////////////////////

$radio = new Radio($ip.":".$port);

// ALL POSSIBLE INFORMATION //
$display_array = array(
                       "Stream Title",
                       "Stream Genre",
                       "Stream URL",
                       "Current Song",
                       "Server Status",
                       "Stream Status",
                       "Listener Peak",
                       "Average Listen Time",
                       "Content Type",
                       "Stream AIM",
                       "Stream IRC"
);

$data_array = $radio->getServerInfo($display_array);

echo "<table style=\"background-color: #CCC; border: 1px solid black;\">\n";

if (is_array($data_array))
{
    foreach ($display_array AS $i => $text)
    {
        if ($text == "Stream Genre")
   {
            $datastring = "<span style=\"color: lightgrey; background-color: black;\">".$data_array[$i]."</span>";
        }
   elseif ($text == "Stream URL")
        {
       $datastring = "<a href=\"".$data_array[$i]."\" target=\"_blank\">".$data_array[$i]."</a>";
        }
   else
        {
       $datastring = $data_array[$i];
        }
   echo "<tr>\n <td>".$text.":</td>\n";
        echo " <td>".$datastring."</td>\n</tr>\n";
    }
}
else
{
    echo "<tr>\n <td colspan=\"2\" style=\"color: red;\">".$data_array."</td>\n</tr>\n";
}
echo "</table>\n";

/*SONG HISTORY*/
echo "<h2>Song History</h2>\n";

echo $radio->getHistoryTable("/played.html", "<b>Played At</b>", "<b>Song</b>", "songOverview");
?>
</body>
</html>
Ferik
 
Posts: 11
Joined: Thu 14th Jan, 2010 11:37 am

Re: last songs played

Postby Gavin » Thu 21st Jan, 2010 2:55 pm

That looks like a decent script, thanks for posting 8)
Please don't PM me for support, support system located at:
Customer Support: https://secure.bellonline.co.uk/submitticket.php
FreeStreamHosting Support: http://freestreamhosting.org/support.php
Sales: https://secure.bellonline.co.uk/contact.php
Gavin
Site Admin
 
Posts: 346
Joined: Thu 01st Jan, 1970 1:00 am

Re: last songs played

Postby Ferik » Thu 21st Jan, 2010 5:33 pm

if you want History Song only, this is the code, remember to download the shoutcast class ........ very simple :)

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>myRadio Test Page</title>
<style type="text/css">
.myRadio {
       width:30%;
       border:1px solid black;
       background-color: #EEE;
}
.myRadio td {
       padding: 1px 10px 1px 1px;
}
   </style>
</head>
<body>

<?php

require_once ('shoutcast_class.php');

///YOUR RADIO CONFIGURATION IP & PORT///
$radio_ip   = "stream_address_here";
$radio_port = "port_here";

$my_radio = new Radio($radio_ip.":".$radio_port);

/*SONG HISTORY*/
echo "<h2>Song History</h2>\n";
echo $my_radio->getHistoryTable("/played.html", "<b>Played At</b>", "<b>Song</b>", "myRadio");

?>
  </body>
</html>
Ferik
 
Posts: 11
Joined: Thu 14th Jan, 2010 11:37 am

Re: last songs played

Postby djboro88 » Fri 13th Aug, 2010 7:59 am

Hi good morning.
I would like that same code, make some kind of script or the same code but I only extracted the Strem Genre and also to change the name of that variable, for example: instead of Stream Genre to display: PROGRAM:

Greetings and thanks.
djboro88
 
Posts: 3
Joined: Wed 28th Apr, 2010 3:37 pm

Re: last songs played

Postby Gavin » Fri 13th Aug, 2010 2:55 pm

Thanks for posting your script. Here's an alternative one that I made a few weeks ago which doesn't require the Shoutcast_class (which I'm getting a 'forbidden' error on when following the link). The results are inside a table which is formatted in the same way as played.html:

Code: Select all
<?php

$server_ip = "YOUR SERVER ADDRESS";
$portbase = "YOUR SERVER PORT";

if (!is_numeric($portbase)) {
    print "Invalid port";
    exit;
}
$fp = @fsockopen($server_ip,$portbase,$errno,$errstr,1);
if (!$fp) {
    print "<p>Connection refused, the server appears to be offline.</p>";
    exit;
} else {
    fputs($fp, "GET /played.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
    while (!feof($fp)) {
        $info = fgets($fp);
    }
    $content = get_string_between($info, "Admin Login</a></font></td></tr></table></td></tr></table><br>", "<br><br><table");
    print $content;
    fclose($fp);
}

function get_string_between($string, $start, $end) {
    $string = " " . $string;
    $ini = strpos($string, $start);
    if ($ini == 0)
      return "";
    $ini += strlen($start);
    $len = strpos($string, $end, $ini) - $ini;
    return substr($string, $ini, $len);
}
?>
Please don't PM me for support, support system located at:
Customer Support: https://secure.bellonline.co.uk/submitticket.php
FreeStreamHosting Support: http://freestreamhosting.org/support.php
Sales: https://secure.bellonline.co.uk/contact.php
Gavin
Site Admin
 
Posts: 346
Joined: Thu 01st Jan, 1970 1:00 am

Re: last songs played

Postby mgajic » Fri 10th Sep, 2010 5:56 pm

is there a way to get this list without PHP ... in simple html/java?
mgajic
 
Posts: 1
Joined: Fri 10th Sep, 2010 5:54 pm

Re: last songs played

Postby Gavin » Tue 14th Sep, 2010 5:52 pm

mgajic wrote:is there a way to get this list without PHP ... in simple html/java?


Unfortunately, there's a simple answer: No

You need some kind of server side language to process the data from the Shoutcast server.
Please don't PM me for support, support system located at:
Customer Support: https://secure.bellonline.co.uk/submitticket.php
FreeStreamHosting Support: http://freestreamhosting.org/support.php
Sales: https://secure.bellonline.co.uk/contact.php
Gavin
Site Admin
 
Posts: 346
Joined: Thu 01st Jan, 1970 1:00 am

Re: last songs played

Postby themarty » Sun 26th Sep, 2010 9:07 pm

Gavin wrote:Thanks for posting your script. Here's an alternative one that I made a few weeks ago which doesn't require the Shoutcast_class (which I'm getting a 'forbidden' error on when following the link).


My hosting provider had some problems which is why the 403 was issued. The problems have been resolved though and the website is back online. I've even posted a new, improved, version of the class containing new features:

http://devshed.excudo.net/scripts/php/s ... rnet+radio

Besides shoutcast, it can also retrieve and parse information from icecast and steamcast servers.
One of the new features is an improved way to exercise control over the output by means of a templating system.

Gavin wrote:You need some kind of server side language to process the data from the Shoutcast server.


Although i also think html+javascript won't work, the comment itself is not entirely true. A clientside language could also do the job. Javascript can do this, in theory, although most browsers will probably prevent it because they don't allow information from different domains to interact (but that's not a restriction of the language itself). But, for example, if you were to create an extension for firefox, this restriction wouldn't apply and i'm quite sure you would be able to load and parse the data (using a clientside language). Flash could be an option too, although the same restrictions might apply - i don't know cuz i'm not a flash expert.
themarty
 
Posts: 1
Joined: Fri 24th Sep, 2010 1:56 pm


Return to Streaming Discussion

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest


Website Navigation

For Your Information

Service Updates

Service Status & Stats

Knowledgebase

Community Forums

Contact Details

Sales and General Enquiries

Support Centre

Our Services

MixStream.net
Media streaming services

UKHostingDirect.com
Shared and reseller hosting

LowCostDedi.net
Value dedicated servers

Cast-Control-LITE.net
Licenses from just £2.70

Legal Information

Any personal information we collect on this page will be treated in accordance with our privacy policy.
By viewing this website, you agree to the Website Terms of Use.

Copyright © 2012 Bell Online Ltd. Registered in England & Wales 7234972. W3C Valid - HTML

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO