Jump to content

Icecast Last 12 Tracks


dustyfoo

Recommended Posts

I am using php to show last 12 tracks what were played on a radio station, the existing script works, however, I need to modify it so it only shows last 12 results from lines what contain '/stream':

 

example of playlist.log

 

01/May/2015:11:45:44 +0000|/live|0|Dense & Pika - Black Deep
01/May/2015:11:45:44 +0000|/stream|11|Dense & Pika - Black Deep
01/May/2015:11:45:48 +0000|/stream|11|DJ Mays - Big Room Session Mix (#111,112 TRTM)
01/May/2015:11:46:00 +0000|/live|0|Dense & Pika - Black Deep
01/May/2015:11:46:00 +0000|/stream|11|Dense & Pika - Black Deep
01/May/2015:11:46:05 +0000|/stream|11|DJ Mays - Big Room Session Mix (#111,112 TRTM)
 

 

here is the existing script:

 

http://dpaste.com/05XYG7G.txt

 

 

Hope you can help :)

Link to comment
https://forums.phpfreaks.com/topic/296018-icecast-last-12-tracks/
Share on other sites

Try changing these lines

while (! feof($fp)) {
        $parts = fgetcsv($fp, 0, '|');
        echo fgets($page). "<br />";
        if (count($parts) !== 4) {
                continue;
        }

to

while (($parts = fgetcsv($fp, 0, '|'))  !== FALSE)
{
        if ((count($parts) != 4) || (strpos($parts[1], '/stream') === false)) {
                continue;
        }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.