https://github.com/andreztz/pyradios
A Client for the Radio Browser API
https://github.com/andreztz/pyradios
api data-collection entertainment internet-radio internet-radio-stations music open-api python radio-browser radio-stations streaming
Last synced: about 1 month ago
JSON representation
A Client for the Radio Browser API
- Host: GitHub
- URL: https://github.com/andreztz/pyradios
- Owner: andreztz
- License: mit
- Created: 2018-09-03T07:45:41.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2025-04-27T03:05:47.000Z (about 2 months ago)
- Last Synced: 2025-04-27T04:19:08.340Z (about 2 months ago)
- Topics: api, data-collection, entertainment, internet-radio, internet-radio-stations, music, open-api, python, radio-browser, radio-stations, streaming
- Language: Python
- Homepage: https://api.radio-browser.info/
- Size: 169 KB
- Stars: 68
- Watchers: 4
- Forks: 24
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pyradios

> A Python client for the [Radio Browser API](https://api.radio-browser.info), allowing users to search and filter thousands of online radio stations.
## π₯ Installation
Install `pyradios` via pip:
```sh
pip install pyradios```
## π Usage
### Basic Example
```python
from pyradios import RadioBrowserrb = RadioBrowser()
results = rb.search(name="BBC Radio 1", name_exact=True)print(results)
```
### Sample Output
```json
[
{
"changeuuid": "4f7e4097-4354-11e8-b74d-52543be04c81",
"stationuuid": "96062a7b-0601-11e8-ae97-52543be04c81",
"name": "BBC Radio 1",
"url": "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p",
"homepage": "http://www.bbc.co.uk/radio1/",
"tags": "bbc,indie,entertainment,music,rock,pop",
"country": "United Kingdom",
"countrycode": "GB",
"language": "english",
"codec": "MP3",
"bitrate": 128
}
]```
## π Faceted Search with `RadioFacets`
### What is `RadioFacets`?
`RadioFacets` extends `RadioBrowser` by providing faceted search functionality. It allows you to filter radio stations by various attributes such as:
- **Tags** (`tags`)
- **Country Code** (`countrycode`)
- **Language** (`language`)
- **State/Region** (`state`)
- **Audio Codec** (`codec`)### Example: Using `RadioFacets`
```python
from pyradios import RadioBrowser, RadioFacetsrb = RadioBrowser()
rf = RadioFacets(rb)print(len(rf)) # Total stations available
rf_be = rf.narrow(countrycode="BE") # Narrow by Belgium (BE)
print(len(rf_be))rf_nl = rf_be.narrow(language="dutch") # Further narrow by Dutch language
print(len(rf_nl))rf_reset = rf_nl.broaden(countrycode="BE", language="dutch") # Remove filters
print(len(rf_reset)) # Back to original count```
### Explanation
- **`narrow(**params)`** β Adds filters and narrows results.
- **`broaden(*keys, **params)`** β Removes filters and broadens results.
- **`len(rf)`** β Returns the number of stations matching the filters.
- **`rf.result`** β Stores the list of filtered stations.### Example Output
```sh
53768 # Total available stations
398 # Stations in Belgium
108 # Dutch-speaking stations in Belgium
53768 # Reset back to all stations```
## π Documentation
To explore all available methods and options, use Pythonβs built-in `help()` function:
```python
from pyradios import RadioBrowser, RadioFacetshelp(RadioBrowser)
help(RadioFacets)```
## π Development Setup
Clone the repository and set up the environment:
```sh
git clone https://github.com/andreztz/pyradios.git
cd pyradios
virtualenv venv
source venv/bin/activate
pip install -e .[dev]```
## β Running Tests
Execute the test suite using `pytest`:
```sh
pytest```
## π Release History
- **Work in progress**
## π License
Distributed under the MIT License. See `LICENSE` for more details.
## π₯ Contributing
Contributions are welcome! Follow these steps to contribute:
1. **Fork the repository** ([https://github.com/andreztz/pyradios/fork](https://github.com/andreztz/pyradios/fork))
2. **Create a feature branch** (`git checkout -b feature/fooBar`)
3. **Commit your changes** (`git commit -am 'Add feature fooBar'`)
4. **Push to your branch** (`git push origin feature/fooBar`)
5. **Submit a Pull Request**----------
π§ **Author:** Andre P. Santos β [@ztzandre](https://twitter.com/ztzandre) β [[email protected]](mailto:[email protected])
GitHub: [https://github.com/andreztz](https://github.com/andreztz/)