adinan-cenci/radio-browser

A library to fetch radio stations from the radio-browser.info catalog.

2.1.0 2022-03-05 12:11 UTC

This package is auto-updated.

Last update: 2024-11-05 18:08:39 UTC


README

A library to fetch data from the radio-browser.info catalog of Internet radio stations by using the project's api.

use \AdinanCenci\RadioBrowser\RadioBrowser;

$browser          = new RadioBrowser();
$tag              = 'metal';
$orderBy          = 'name';
$descendingOrder  = true;

$stations         = $browser->getStationsByTag($tag, $orderBy, $descendingOrder);

print_r($stations);



Examples

See examples of how to use in the "examples" directory.



Classes and instantiating

Associative arrays / Objects

The methods of \AdinanCenci\RadioBrowser\RadioBrowser will return either associative arrays or stdObjects, depending on the $associative parameter informed to the constructor.



Xml, json, csv etc...

If you need the data represented in a specific format, then use \AdinanCenci\RadioBrowser\RarioBrowserApi. The different methods will return data formatted as: json, xml, csv, m3u, pls, xspf and ttl.



Radio Stations

Get stations by UUID

The ::getStationsByUuid($uuids) search stations with the specified ids.



Get stations by URL

The ::getStationsByUrl($url)method search stations by their web page.



Get stations by clicks

The ::getStationsByClicks($offset, $limit, $hideBroken) method returns the most sintonized stations.



Get stations by votes

The ::getStationsByVotes($offset, $limit, $hideBroken) method returns the most voted stations.



Get stations by recent clicks

The ::getStationsByRecentClicks($offset, $limit, $hideBroken) method returns the currently most popular stations.



Get stations last changed

The ::getStationsByLastChange($offset, $limit, $hideBroken) method returns the stations last updated.



Get older version of stations

The ::getStationOlderVersions($lastChangeUuid, $limit) method returns old versions of stations from the last 30 days.



Get broken stations

The ::getBrokenStations($offset, $limit) method returns stations that did not pass the connection test.



Get stations by ...

All the methods in this section share the following parameters:



Just get all stations

The ::getStations($order, $reverse, $hideBroken, $offset, $limit) method will return all stations.



Get stations by name

The ::getStationsByName($name, $order, $reverse, $hideBroken, $offset, $limit) method returns stations described with $name.



Get stations by exact name

The ::getStationsByExactName($name, $order, $rev...) method returns stations described with an exact match of $name.



Get stations by codec

The ::getStationsByCodec($codec, $order, $rev...) method returns stations described with $codec.



Get stations by exact codec

The ::getStationsByExactCodec($codec, $order, $rev...) method returns stations described with an exact match of $codec.



Get stations by country

::getStationsByCountry($country, $order, $rev...)



Get station by exact country

::getStationsByExactCountry($country, $order, $rev...)



Get stations by state

::getStationsByState($state, $order, $rev...)



Get stations by exact state

::getStationsByExactState($state, $order, $rev...)



Get stations by language

::getStationsByLanguage($language, $order, $rev...)



Get stations by exact language

::getStationsByExactLanguage($language, $order, $rev...).



Get stations by tag

::getStationsByTag($tag, $order, $rev...)



Get stations by exact tag

::getStationsByExactTag($tag, $order, $rev...)



Search station

The ::searchStation($searchTerms) method allow us to fine grain our search. It receives a single associative array with the following keys available, all of which are optional:



Get station checks

The ::getStationCheckResults($stationUuid, $lastCheckUuid, $seconds, $limit) method returns a list of station check results. If a station UUID is provided, the whole history will be returned, otherwise a list of all last checks of all stations will be sent (without older check results).



Get station clicks

The ::getStationClicks($stationUuid, $lastCheckUuid, $seconds) method returns a list of station clicks. If a station UUID is provided, only clicks of the station will be returned, otherwise a list of all clicks of all stations will be sent (chunksize 10000).



Add station

The ::addStation($name, $url, $homePage, $favIcon, $countryCode, $state, $language, $tags, $geoLat, $geoLong) method allow us to insert new stations.

It receives a single associative array with the following keys available, all of which are optional:



Ranking

Listeners

The ::clickStation($stationUuid) method must be invoked every time a user starts playing a stream, this helps Radio Browser sort how popular each station is. IMPORTANT: Every call from the same IP address and for the same station only gets counted once per day.

Voting

The ::voteStation($stationUuid) method increases the vote count by one. IMPORTANT: it can only be called once every 10 minutes for the same radio stations, from the same IP.



General Information

The methods bellow share the following parameters:

Get codecs

The ::getCodecs($filter, $order, $reverse, $hideBroken) method returns a list of codecs and a count of stations using them.



Get languages

The ::getLanguages($filter, $ord...) method returns a list of languages and a count of stations in this language.



Get tags

The ::getTags($filter, $ord...) method returns a list of tags and a count of stations described with them.



Get country codes

The ::getCountryCodes($filter, $ord...) method returns a list of country codes and a count of stations described with them.



Get countries

The ::getCountries($filter, $ord...) method returns a list of countries and a count of stations described with them.



Get states

The ::getStates($filter, $country, $order, $reverse, $hideBroken) return a list of states and a count of stations described with them.



Servers

Get the server's stats

::getServerStats()



Get the server's mirrors

::getServerMirrors()



Get the server's configurations

::getServerConfig()



Get the server's metrics

::getServerMetrics()



Get DNS records

The ::getDnsRecords() static method returns DNS information on available servers.



Get server IPs

The ::getServerIps() static method returns an array of IPs of available servers.



Get servers

The ::getServers() static method returns an array of URLs of available servers.



Pick a server

The ::pickAServer() static method returns a random server's URL.



Installation

Use composer.

composer require adinan-cenci/radio-browser



License

MIT