You are here:  » Getting Icecast information


Getting Icecast information

Submitted by russellharrower on Wed, 2009-11-11 13:33 in

Hi guys, I was using magic parser to get information from http://pplnettv.wnet.ua:8000/status2.xsl

but due to that they have 3 stations listed I need to get the information seperate each station and then get the information

http://pplnettv.wnet.ua:8000/

This was the code your demo gave me

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
// This is where you write your code to process each record, such as loading a database
    // You can display the record contents using PHP's internal print_r() function:
    
print_r($record);
    
// The following code will print out each field in your sample data:
    
print $record["PRE"];
  }
  
MagicParser_parse("http://pplnettv.wnet.ua:8000/status2.xsl","myRecordHandler","xml|PRE/");
?>

but you will see the information in that PRE prints like

MountPoint,Connections,Stream Name,Current Listeners,Description,Currently Playing,Stream URL
Global,Client:1112380 Source: ,,88,,
/1gtv.asf,,,62,, - ,/1tv.asf,,,0,, - ,/bbc-radio1,,,13,, - ,/kissfm,,,363,, - REY-NA,

I don't need any of the information before Source: (including Source:)

I would like it to make an XML file like

1gtv.asf
62

1tv.asf
0

bbc-radio1
13

KissFM
363
- REY-NA

Submitted by support on Wed, 2009-11-11 13:40

Hi Russell,

This should be straight forward to handle; all you need to do is "explode" the value of $record["PRE"] using the delimiter "Source:", trim the result and then you can use the remainder of the value as required; for example:

  function myRecordHandler($record)
  {
    $parts = explode("Source:",$record["PRE"]);
    $text = trim($parts[1]);
    print $text;
  }

Hope this helps!
Cheers,
David.

Submitted by russellharrower on Wed, 2009-11-11 14:35

It must be my bad luck or something, for some reason I cant access that xml feed with your script. I get a blank page.

Submitted by support on Wed, 2009-11-11 14:39

Hi Russell,

Sorry - that wasn't a complete example, just a re-working of the record handler function. Have a go with the following;

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
$parts explode("Source:",$record["PRE"]);
    
$text trim($parts[1]);
    print 
$text;
  }
  
MagicParser_parse("http://pplnettv.wnet.ua:8000/status2.xsl","myRecordHandler","xml|PRE/");
?>

Cheers,
David.

Submitted by russellharrower on Wed, 2009-11-11 14:42

Hi david,
that was the code I was using. I think it is my web host Can you do a test on your server to see if it works, and if it does would you be able to let me know how your hosting provider is. Might need to move providers.

Submitted by support on Thu, 2009-11-12 10:37

Hello Russell,

I checked the code and it is fine - so the problem is most likely that you host is blocking external HTTP access over port 8000. Unless you have a dedicated server (in which case you can permit whatever you want); it would be down to whether or not your host allows external access to a URL on a port other than 80.

Firstly I would contact the support at your hosting company and ask if it is possible to allow this for your account (perhaps also tell them the port number you need to use - 8000 in this case) - and if not then when considering other hosts contact technical help before joining to ask the same. You can even ask them to run a small test script for you; this is all the code you need to test it:

<?php
  header
("Content-Type: text/xml");
  
$xml file_get_contents("http://pplnettv.wnet.ua:8000/status2.xsl");
  print 
$xml;
?>

Hope this helps,
Cheers,
David.