segler-alex / radiobrowser-api

radio browser server api
GNU Affero General Public License v3.0
72 stars 15 forks source link

SHOUTcast Radio Directory: Import 63 000 streams #34

Open davidhedlund opened 7 years ago

davidhedlund commented 7 years ago

The SHOUTcast Radio Directory can be downloaded and used by developers who wish to use it, and there are no non-free restrictions.

We should of course give credit to SHOUTcast on the main page of radio-browser.info if they give us access to the API.

Interesting links

davidhedlund commented 7 years ago

https://github.com/segler-alex/radiobrowser-api/issues/31

davidhedlund commented 7 years ago

https://www.shoutcast.com/Developer says

If you would like to become a SHOUTcast API Partner, please send us an email with details about your company and your proposed application. We'll get back to you.

I filed a request with this text:

We are trying to import your streams to radio-browser.info - https://github.com/segler-alex/radiobrowser-api/issues/34

Please read http://www.radio-browser.info/gui/#/ for information about the growing project.

davidhedlund commented 6 years ago

Well, I got a API key a while ago.

Example how to use it from http://wiki.shoutcast.com/wiki/SHOUTcast_Radio_Directory_API#Get_Top_500_Stations

http://api.shoutcast.com/legacy/Top500?k=[Your Dev ID]

The XML was obfuscated so I had to pretty print it:

xmllint Top500.xml --format

<stationlist>
<?xml version="1.0" encoding="UTF-8"?>
<stationlist>
  <tunein base="/sbin/tunein-station.pls" base-m3u="/sbin/tunein-station.m3u" base-xspf="/sbin/tunein-station.xspf"/>
  <station name="COOLfahrenheit 93 - (7)" mt="audio/mpeg" id="1721052" br="64" genre="Easy Listening" genre2="Pop" logo="http://i.radionomy.com/document/radios/a/a265/a2654f5f-669e-4b9e-ac13-962971886ad2.jpg" ct="Instinct - -B)...+1'C" lc="7202"/>
  <station name="COOLfahrenheit 93 -- (6)" mt="audio/mpeg" id="1634844" br="64" genre="Easy Listening" genre2="Pop" logo="http://i.radionomy.com/document/radios/7/7c48/7c48c133-a1ee-42e6-97fa-6420420e8cad.jpg" ct="Instinct - -B)...+1'C" lc="5708"/>
  <station name="Dance Wave Retro!" mt="audio/mpeg" id="1057402" br="128" genre="International" lc="5413"/>
...
</stationlist>

As you can see, there are no playlists in the XML. I have asked SHOUTcast to include them. I'll get back on this later.

dr0biwan commented 6 years ago

Dunno if this is still relevant or not but you're given all of the information in the SC API responses to be able to generate the SC playlist url as needed.

You assume 'shoutcast.com' & then append the appropriate values from the 'tunein' part of the response (depending on the playlist type you want to use) & then just append the 'id' in the station entry. Though you can probably just assume a hard-coded string for the playlist without using the 'tunein' part & just append the 'id'.

davidhedlund commented 6 years ago

@dr0biwan Can you please give an example for name="Dance Wave Retro!"?

dr0biwan commented 6 years ago

For that example (if going for the m3u version), then you'd have "shoutcast.com/sbin/tunein-station.m3u?id=1057402" as the playlist which then the client / tooling parses to get to the actual stream url(s) (since the directory listing can depending on the station's setup either be made up of 1 server or a cluster of servers).

I should probably note that I used to work maintaining that API & other SC aspects for a few years though whoever is left in support should have been able to give you this information about the playlists (even if it meant pointing you to the wiki docs).

davidhedlund commented 6 years ago

For that example (if going for the m3u version), then you'd have "shoutcast.com/sbin/tunein-station.m3u?id=1057402" as the playlist which then the client / tooling parses to get to the actual stream url(s) (since the directory can depending on the station's setup either be made up of 1 server or a cluster of servers).

Thanks. I just needed to add "http://yp." at the beginning of the URL like this to make it work: http://yp.shoutcast.com/sbin/tunein-station.pls?id=1057402

I should probably note that I used to work maintaining that API & other SC aspects for a few years though whoever is left in support should have been able to give you this information about the playlists (even if it meant pointing you to the wiki docs).

Interesting, do you also got an API account?

dr0biwan commented 6 years ago

It should work without the "http://yp." and just using "http://" so is a bit odd it's not working for the shorter url for you.

I was issued a devid before I was let go though it's not hard to find winamp's own or other peoples devids (not that they're needed for accessing the tunein links).

davidhedlund commented 6 years ago

It should work without the "http://yp." and just using "http://" so is a bit odd it's not working for the shorter url for you.

Yes, http://shoutcast.com/sbin/tunein-station.pls?id=1057402 (VLC requires "https://") also worked. Thanks.