adinan-cenci/radio-browser
Composer 安装命令:
composer require adinan-cenci/radio-browser
包简介
A library to fetch radio stations from the radio-browser.info catalog.
README 文档
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.
- Get tags
- Get states
- Get stations by tag
- Get stations by country
- Get stations by clicks
- Get stations by votes
- Get stations in XML format
- Get servers IPs
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| $server | string|bool | https://de1.api.radio-browser.info/ | A Radio Browser server, it defaults to "'https://de1.api.radio-browser.info/", if false is informed the object will pick a random server, see the server section for more information. |
| $associative | bool | true | If true, the methods will return associative arrays, stdObjects otherwise. |
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| $server | string|bool | https://de1.api.radio-browser.info/ | A Radio Browser server, it defaults to "'https://de1.api.radio-browser.info/", if false is informed, the object will pick a random server, see the server section for more information. |
| $format | string | json | The format the data must be served, possible values: json, xml, csv, m3u, pls, xspf, ttl. |
Radio Stations
Get stations by UUID
The ::getStationsByUuid($uuids) search stations with the specified ids.
| Parameter | Type | Description |
|---|---|---|
| $uuids | string|array | A list of uuids, either an array, or an comma separated string. |
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
| $order | string | 'name' | Possible values: name, url, homepage, favicon, tags, country, state, language, votes, codec, bitrate, lastcheckok, lastchecktime, clicktimestamp, clickcount, clicktrend, random. |
| $reverse | bool | false | false = Ascending order. true = Descending order. |
| $hideBroken | bool | false | Do not list stations that failed the connection test. |
| $offset | int | 0 | |
| $limit | int | 100000 |
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:
| Key | Type | Default | Description |
|---|---|---|---|
| name | string | null | |
| nameExact | bool | false | |
| country | string | null | |
| countryExact | bool | false | |
| countrycode | string | null | |
| state | string | null | |
| stateExact | bool | false | |
| language | string | null | |
| languageExact | bool | false | |
| tag | string | null | |
| tagExact | bool | false | |
| tagList | string|array | null | A list of tags, either an array or a comma separated string. |
| codec | string | null | |
| bitrateMin | int | 0 | |
| bitrateMax | int | 1000000 | |
| order | string | name | Possible values: name, url, homepage, favicon, tags, country, state, language, votes, codec, bitrate, lastcheckok, lastchecktime, clicktimestamp, clickcount, clicktrend, random. |
| reverse | bool | false | false = Ascending order. true = Descending order. |
| offset | int | 0 | |
| limit | int | 100000 |
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).
| Parameter | Type | Default | Description |
|---|---|---|---|
| $stationUiid | 'string' | Optional. If set, only list check result of the matching station. | |
| $lastCheckUuid | 'string' | If set, only list checks after the check with the given check. | |
| $seconds | integer | 0 | if > 0, it will only return history entries from the last $seconds seconds. |
| $limit | integer | 999999 |
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).
| Parameter | Type | Default | Description |
|---|---|---|---|
| $stationUiid | 'string' | Optional. If set, only list check result of the matching station. | |
| $lastCheckUuid | 'string' | If set, only list checks after the check with the given check. | |
| $seconds | integer | 0 | if > 0, it will only return history entries from the last $seconds seconds. |
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:
| Key | Type | Default | Description |
|---|---|---|---|
| $name | string | MANDATORY, the name of the radio station. Max 400 chars. | |
| $rl | string | MANDATORY, the URL of the station. | |
| $homePage | string | null | the homepage URL of the station. |
| $favIcon | string | null | the URL of an image file (jpg or png). |
| $countryCode | string | null | The 2 letter countrycode of the country where the radio station is located. |
| $state | string | null | The name of the part of the country where the station is located. |
| $language | string | null | The main language used in spoken text parts of the radio station. |
| $tags | string | null | A list of tags separated by commas to describe the station. |
| $geoLat | string | null | The latitude of the stream location. |
| $geoLong | string | null | The longitude of the stream location. |
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
| $filter | string | A string to be matched against. | |
| $order | string | name | Possible values: name, stationcount. |
| $reverse | bool | false | false = Ascending order. true = Descending order. |
| $hideBroken | bool | false | Do not count stations that failed the connection test. |
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| $filter | string | A string to be matched against. | |
| $country | string | null | The country that the state belongs to. |
| $order | string | name | Possible values: name, stationcount. |
| $reverse | bool | false | false = Ascending order. true = Descending order. |
| $hideBroken | bool | false | Do not count stations that failed the connection test. |
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
adinan-cenci/radio-browser 适用场景与选型建议
adinan-cenci/radio-browser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 195 次下载、GitHub Stars 达 12, 最近一次更新时间为 2021 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「music」 「radio」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adinan-cenci/radio-browser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adinan-cenci/radio-browser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adinan-cenci/radio-browser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Use JSON templates as field options for dropdown, radio or checkboxes.
MvcCore - Extension - Form - form extension with base classes to create and render web forms with HTML5 controls, to handle and validate submited user data, to manage forms sessions for default values, to manage user input errors and to extend and develop custom fields and field groups.
PHP wrapper for command-line fingerprint generator - fpcalc
Library that obtains VK tokens that work for VK audio API. Библиотека для получения токена VK, подходящего для Audio API.
Attribute RadioImage for Isotope eCommerce
Object Oriented PHP Wrapper for acoustid.org API
统计信息
- 总下载量: 195
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-22