0

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 Answers2

0

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.

  • Thank you I will try it later, why should it be illegal? I can open all the streams one by one and it is not illegal. I can download a plugin for an audio player and listen all the streams. So please tell me what could be illegal in all that. – user1574467 Aug 07 '12 at 08:08
  • Yes, it's okay to open them. But that's not what you're doing here. You're **taking** them. You could use this to setup your own app, duplicating them. And I never said it was illegal, but It could easily be breaching a copyright law. –  Aug 07 '12 at 08:13
  • My intent is to create a little database with the urls, so the app can open it instead to open each time the site to listen a new radio. – user1574467 Aug 07 '12 at 08:24
  • Please I need to know if it is not legal or violate the copyright – user1574467 Aug 07 '12 at 08:24
  • So now you want **me** to read their copyright laws, even after spending like half an hour writing that code for you? Hahaha, you're funny. –  Aug 07 '12 at 08:25
  • I'm not asking that, I thought you knew the subject :D – user1574467 Aug 07 '12 at 08:33
  • I'm here to help people with their code. Not with their legal issues. –  Aug 07 '12 at 08:35
0

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.

mario
  • 144,265
  • 20
  • 237
  • 291