Old 10th February 2004, 05:36   #1
Boyer
Junior Member
 
Join Date: Feb 2004
Posts: 2
HOW-TO: Get SC playlist file

I badly needed a way to dynamicly link to the SC stream of the radio station I work for. We broadcast a stream from a 3rd party computer, and it doesn't have a static address. So, I came up with a quick and dirty piece of PHP code to get the playlist file from shoutcast.com. It uses the search query to return the file.

NOTE: You *MUST* have fopen wrappers enabled to use this funtcion. If you have PHP3 or PHP4 < 4.3.0, you'll need a walk around for the file_get_contents() function. You can find that here.

Here is the function part of it:

PHP Code:
// Get the current SHOUTcast playlist
function getSC($query) {

// Get the page that displays a link to tune into the station you've queried
$handle=file_get_contents("http://www.shoutcast.com/directory/index.phtml?s=$query"r);

    
$start=strpos("$handle""/sbin");
    
$new=strstr("$handle""/sbin");
    
$end=strpos("$new""filename.pls");
    
$result=substr("$handle"$start$end);

    Return 
$result;

Here's an example of how to get your address:
code:

<html>
<body>
<?php
$query="My Station";
$result=getSC($query);
?>
<a href="http://www.shoutcast.com<?php
echo $result; ?>filename.php"><?php echo $query; ?></a>
</body>
</html>



Hope this helps someone! If anyone knows of a simpler and/or faster way to do this, pleas contact me at: sean@boyercentral.net

Cheers!
Boyer is offline   Reply With Quote
Old 10th February 2004, 08:54   #2
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
i wouldn't recommend using this script, SHOUTcast.com keeps track of usages from the location of your script and will eventually block it if you get loads of traffic to it.
Jay is offline   Reply With Quote
Old 10th February 2004, 12:00   #3
Boyer
Junior Member
 
Join Date: Feb 2004
Posts: 2
Well, maybe 5-10 hits a day for now. I wouldn't consider that loads... Anyway, is there any easier way? I mean, I NEED to do this somehow! Help would be much appreciated!

Thanks for the heads up btw
Boyer is offline   Reply With Quote
Old 10th February 2004, 12:49   #4
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
how about keeping track of your ip yourself or using a no-ip or other such dynamic ip to hostname services. Relying on the SHOUTcast yp is actually against the terms of service any way and takes away valuable resources from their system. For the completely lazy just link to a search of your station on the yp. At least then shoutcast.com will get ad revenue from the hit.
Jay is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump