How to obtain all the radio urls of xiph.org

1k Views Asked by At

Is there any way to obtain all the URLs from xiph.org? Is there a way to query directly the site to obtain a specified radio or a specified category of radios from a web application?

2

There are 2 best solutions below

7
AudioBubble On

Okay I've had a look at a few of those streams on that site.

If you open the XSPF files in a text editor, you get some XML, with the streams wrapped in the <location> tab.

You're going to have to setup some kind of crawler for this. I'll just make a simple one for you.

//define the link
$link = 'http://dir.xiph.org/';

//get the contents
$contents = file_get_contents($link);

preg_match_all('|"/listen/(.*)/listen.m3u"|',$contents,$match);


//define xspf link array
$xspfLinks = array();

//define default link
$xspfLink = 'http://dir.xiph.org/listen/';

//define final stream array
$finalStream=array();

foreach ($match[1] as $id )
{
    //assign ID to default link and throw it in the array
    $xspfLinks[]=$xspfLink.$id.'/listen.xspf';

}

// now loop through that array
foreach ($xspfLinks as $hehehe )
{
    //download xspf file
    $xspf = file_get_contents($hehehe);

    if(preg_match('|<location>(.*)</location>|',$xspf,$heheMatch))
    {

        //put stream url in final array
        $finalStream[]=$heheMatch[1];
        //test it
        echo 'HEHEHEHE I just stole:'.$heheMatch[1]."<br>";

    }
}

//now do as you please with $finalStream (it will contain all your stream urls)

I just done it all for you -_-. But yeah, that should work.

Oh and one more thing, If you are being silly and stealing those streams when you shouldn't be, I will not be held responsible.

0
mario On

Xiph.org is working on a JSON API (#tkt1958) now. The encoding is still vastly broken due to mysqls CONCAT(json_object(m.stream_name... query.

But even with a regex JSON extraction it's speedier and easier to use than processing the old yp.xml.