pylav.extension.radio package#

Submodules#

pylav.extension.radio.base_url module#

exception pylav.extension.radio.base_url.Error(message=None, *args)[source]#

Bases: PyLavException

Base class for all exceptions raised by this module

exception pylav.extension.radio.base_url.RDNSLookupError(ip)[source]#

Bases: Error

Raised when there was a problem with performing reverse dns lookup for ip.

ip#
port#
async pylav.extension.radio.base_url.fetch_servers()[source]#

Get IP of all currently available Radio Browser servers. :returns: List of addresses. :rtype: set

async pylav.extension.radio.base_url.pick_base_url(session)[source]#

Pick a base url for the RadioBrowser API.

pylav.extension.radio.objects module#

class pylav.extension.radio.objects.Codec(*, name=None, stationcount=None)[source]#

Bases: object

A codec from the RadioBrowser API.

name#
stationcount#
class pylav.extension.radio.objects.Country(*, name=None, iso_3166_1=None, stationcount=None)[source]#

Bases: object

A country from the RadioBrowser API.

iso_3166_1#
name#
stationcount#
class pylav.extension.radio.objects.CountryCode(*, name=None, stationcount=None)[source]#

Bases: object

A country code from the RadioBrowser API.

name#
stationcount#
class pylav.extension.radio.objects.Language(*, name=None, iso_639=None, stationcount=None)[source]#

Bases: object

A language from the RadioBrowser API.

iso_639#
name#
stationcount#
class pylav.extension.radio.objects.State(*, name=None, country=None, stationcount=None)[source]#

Bases: object

A state from the RadioBrowser API.

country#
name#
stationcount#
class pylav.extension.radio.objects.Station(*, radio_api_client, changeuuid=None, stationuuid=None, serveruuid=None, name=None, url=None, url_resolved=None, homepage=None, favicon=None, tags=None, country=None, countrycode=None, iso_3166_2=None, state=None, language=None, languagecodes=None, votes=None, lastchangetime=None, lastchangetime_iso8601=None, codec=None, bitrate=None, hls=None, lastcheckok=None, lastchecktime=None, lastchecktime_iso8601=None, lastcheckoktime=None, lastcheckoktime_iso8601=None, lastlocalchecktime=None, lastlocalchecktime_iso8601=None, clicktimestamp=None, clicktimestamp_iso8601=None, clickcount=None, clicktrend=None, ssl_error=None, geo_lat=None, geo_long=None, has_extended_info=None)[source]#

Bases: object

A station from the RadioBrowser API.

bitrate#
changeuuid#
async click()[source]#

Increase the click count of a station by one.

This should be called everytime when a user starts playing a stream to mark the stream more popular than others. Every call to this endpoint from the same IP address and for the same station only gets counted once per day.

clickcount#
clicktimestamp#
clicktimestamp_iso8601#
clicktrend#
codec#
country#
countrycode#
favicon#
geo_lat#
geo_long#
async get_query()[source]#
has_extended_info#
hls#
homepage#
iso_3166_2#
language#
languagecodes#
lastchangetime#
lastchangetime_iso8601#
lastcheckok#
lastcheckoktime#
lastcheckoktime_iso8601#
lastchecktime#
lastchecktime_iso8601#
lastlocalchecktime#
lastlocalchecktime_iso8601#
name#
radio_api_client#
serveruuid#
ssl_error#
state#
stationuuid#
tags#
url#
url_resolved#
votes#
class pylav.extension.radio.objects.Tag(*, name=None, stationcount=None)[source]#

Bases: object

A tag from the RadioBrowser API.

name#
stationcount#

pylav.extension.radio.radios module#

class pylav.extension.radio.radios.RadioBrowser(client)[source]#

Bases: object

This class implements the main interface for the Radio Browser API.

property base_url#

The base URL for the Radio Browser API.

async click(station=None, station_id=None)[source]#

Increase the click count of a station by one.

This should be called everytime when a user starts playing a stream to mark the stream more popular than others. Every call to this endpoint from the same IP address and for the same station only gets counted once per day.

Parameters:
  • station (Station, optional) – The station to click.

  • station_id (str, optional) – The station uuid to click.

async click_counter(stationuuid)[source]#

Increase the click count of a station by one.

This should be called everytime when a user starts playing a stream to mark the stream more popular than others. Every call to this endpoint from the same IP address and for the same station only gets counted once per day. The call will return detailed information about the stat stream, supported output formats: JSON

Parameters:

stationuuid (str) – A globally unique identifier for the station.

Returns:

A dict containing informations about the radio station.

Return type:

dict

See details:

https://de1.api.radio-browser.info/#Count_station_click

codecs(codec=None)[source]#

Lists all codecs.

Parameters:

codec (str, optional) – Filter by codec. Defaults to None.

Returns:

Codecs.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_codecs

countries(code=None)[source]#

Lists all countries.

Parameters:

code (str, optional) – Filter by country code. Defaults to None.

Returns:

Countries.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_countries

countrycodes(code=None)[source]#

Lists all countries.

Parameters:

code (str, optional) – Filter by country code. Defaults to None.

Returns:

Countries.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_countrycodes

property disabled#

Whether the extension is disabled.

async initialize()[source]#
languages(language=None)[source]#

Lists all languages.

Parameters:

language (str, optional) – Filter by language. Defaults to None.

Returns:

Languages.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_languages

search(**kwargs)[source]#

Advanced search.

It will search for the station whose attribute contains the search term.

Arguments:#

name (str, optional): Name of the station. name_exact (bool, optional): Only exact matches, otherwise all

matches (default: False).

country (str, optional): Country of the station. country_exact (bool, optional): Only exact matches, otherwise

all matches (default: False).

countrycode (str, optional): 2-digit countrycode of the station

(see ISO 3166-1 alpha-2)

state (str, optional): State of the station. state_exact (bool, optional): Only exact matches, otherwise all

matches. (default: False)

language (str, optional): Language of the station. language_exact (bool, optional): Only exact matches, otherwise

all matches. (default: False)

tag (str, optional): Tag of the station. tag_exact (bool, optional): Only exact matches, otherwise all

matches. (default: False)

tag_list (str, optional): A comma-separated list of tag. bitrate_min (int, optional): Minimum of kbps for bitrate field of

stations in result. (default: 0)

bitrate_max (int, optional): Maximum of kbps for bitrate field of

stations in result. (default: 1000000)

order (str, optional): The result list will be sorted by: name,

url, homepage, favicon, tags, country, state, language, votes, codec, bitrate, lastcheckok, lastchecktime, clicktimestamp, clickcount, clicktrend, random

reverse (bool, optional): Reverse the result list if set to true.

(default: false)

offset (int, optional): Starting value of the result list from

the database. For example, if you want to do paging on the server side. (default: 0)

limit (int, optional): Number of returned datarows (stations)

starting with offset (default 100000)

hidebroken (bool, optional): do list/not list broken stations.

Note: Not documented in the “Advanced Station Search”.

returns:

Station.

rtype:

list

See details:

https://de1.api.radio-browser.info/#Advanced_station_search

states(country=None, state=None)[source]#

Lists all states.

Parameters:
  • country (str, optional) – Filter by country. Defaults to None.

  • state (str, optionla) – Filter by state. Defaults to None.

Returns:

States.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_states

async station_by_uuid(stationuuid)[source]#

Radio station by stationuuid.

Parameters:

stationuuid (str) – A globally unique identifier for the station.

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations(**kwargs)[source]#

Lists all radio stations.

Returns:

Stations.

Return type:

list

See details:

https://nl1.api.radio-browser.info/#List_of_all_radio_stations

async stations_by_clicks(limit, **kwargs)[source]#

A list of the stations that are clicked the most.

Parameters:

limit – Number of wanted stations

Returns:

Stations.

Return type:

list

See details:

https://nl1.api.radio-browser.info/#Stations_by_clicks

async stations_by_codec(codec, exact=False, **kwargs)[source]#

Lists all radio stations by codec.

Parameters:
  • codec (str) – The name of the codec.

  • exact (bool) – if the search should search for a station with the exact codec

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_country(country, exact=False, **kwargs)[source]#

Lists all radio stations by country.

Parameters:
  • country (str) – The name of the country.

  • exact (bool) – if the search should search for a station with the exact country

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_countrycode(code, **kwargs)[source]#

Lists all radio stations by country code.

Arguments:#

code (str): Official countrycodes as in ISO 3166-1 alpha-2. exact (bool): if the search should search for a station with the exact code

returns:

Stations.

rtype:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_language(language, exact=False, **kwargs)[source]#

Lists all radio stations by language.

Parameters:
  • language (str) – The name of the language.

  • exact (bool) – if the search should search for a station with the exact language

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_name(name, exact=False, **kwargs)[source]#

Lists all radio stations by name.

Parameters:
  • name (str) – The name of the station.

  • exact (bool) – if the search should search for a station with the exact name

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_state(state, exact=False, **kwargs)[source]#

Lists all radio stations by state.

Parameters:
  • state (str) – The name of the state.

  • exact (bool) – if the search should search for a station with the exact state

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_tag(tag, exact=False, **kwargs)[source]#

Lists all radio stations by tag.

Parameters:
  • tag (str) – The name of the tag.

  • exact (bool) – If set to True, the tag must be exactly the same as the given tag.

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_tag_list(tag_list, **kwargs)[source]#

Lists all radio stations by tag. Must match all tags exactly.

Parameters:

tag_list (list) – A list of names of tags.

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_votes(limit, **kwargs)[source]#

A list of the highest-voted stations.

Parameters:

limit – Number of wanted stations

Returns:

Stations.

Return type:

list

See details:

https://nl1.api.radio-browser.info/#Stations_by_votes

tags(tag=None)[source]#

Lists all tags.

Parameters:

tag (str, optional) – Filter by tag. Defaults to None.

Returns:

Tags.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_tags

class pylav.extension.radio.radios.Request(headers=None, cached_session=None, session=None)[source]#

Bases: object

A wrapper for the aiohttp client.

async get(url, skip_cache=False, **kwargs)[source]#

pylav.extension.radio.utils module#

exception pylav.extension.radio.utils.Error[source]#

Bases: Exception

Base class for all exceptions raised by this module

exception pylav.extension.radio.utils.IllegalArgumentError[source]#

Bases: Error

Raised for illegal argument

class pylav.extension.radio.utils.TransformerCache[source]#

Bases: object

A class to cache the data from the RadioBrowser API.

classmethod build_filter(**kwargs)[source]#

Build a filter dict from the given kwargs.

classmethod clear_cache()[source]#
async classmethod fill_cache(client)[source]#

Fill the cache with data from the RadioBrowser API.

classmethod fill_choice_cache()[source]#

Fill the choice cache with data from the cache.

async classmethod filter_cache(cache_type, limit=25, **kwargs)[source]#

Filter the cache by the given type and kwargs.

classmethod get_codec_cache()[source]#

Get the codec cache.

classmethod get_country_cache()[source]#

Get the country cache.

classmethod get_country_code_cache()[source]#

Get the country code cache.

classmethod get_language_cache()[source]#

Get the language cache.

classmethod get_state_cache()[source]#

Get the state cache.

classmethod get_station_cache()[source]#

Get the station cache.

classmethod get_tag_cache()[source]#

Get the tag cache.

async classmethod get_top_25_stations()[source]#

Get the top 25 stations by vote count.

pylav.extension.radio.utils.bool_to_string(boolean)[source]#

Convert a boolean type to string.

Parameters:

boolean (bool) – A Boolean.

Raises:

TypeError

Returns:

String representation of a bool type.

Return type:

str

pylav.extension.radio.utils.radio_browser_adapter(**kwargs)[source]#

Converts the keyword arguments to the format required by the RadioBrowser API.

pylav.extension.radio.utils.snake_to_camel(string)[source]#

Convert a snake case string to camel case.

pylav.extension.radio.utils.type_check(func)[source]#

Decorator to check the type of the input data.

pylav.extension.radio.utils.validate_input(type_value, input_data)[source]#

Validate the input data.

Module contents#

class pylav.extension.radio.RadioBrowser(client)[source]#

Bases: object

This class implements the main interface for the Radio Browser API.

property base_url#

The base URL for the Radio Browser API.

async click(station=None, station_id=None)[source]#

Increase the click count of a station by one.

This should be called everytime when a user starts playing a stream to mark the stream more popular than others. Every call to this endpoint from the same IP address and for the same station only gets counted once per day.

Parameters:
  • station (Station, optional) – The station to click.

  • station_id (str, optional) – The station uuid to click.

async click_counter(stationuuid)[source]#

Increase the click count of a station by one.

This should be called everytime when a user starts playing a stream to mark the stream more popular than others. Every call to this endpoint from the same IP address and for the same station only gets counted once per day. The call will return detailed information about the stat stream, supported output formats: JSON

Parameters:

stationuuid (str) – A globally unique identifier for the station.

Returns:

A dict containing informations about the radio station.

Return type:

dict

See details:

https://de1.api.radio-browser.info/#Count_station_click

codecs(codec=None)[source]#

Lists all codecs.

Parameters:

codec (str, optional) – Filter by codec. Defaults to None.

Returns:

Codecs.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_codecs

countries(code=None)[source]#

Lists all countries.

Parameters:

code (str, optional) – Filter by country code. Defaults to None.

Returns:

Countries.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_countries

countrycodes(code=None)[source]#

Lists all countries.

Parameters:

code (str, optional) – Filter by country code. Defaults to None.

Returns:

Countries.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_countrycodes

property disabled#

Whether the extension is disabled.

async initialize()[source]#
languages(language=None)[source]#

Lists all languages.

Parameters:

language (str, optional) – Filter by language. Defaults to None.

Returns:

Languages.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_languages

search(**kwargs)[source]#

Advanced search.

It will search for the station whose attribute contains the search term.

Arguments:#

name (str, optional): Name of the station. name_exact (bool, optional): Only exact matches, otherwise all

matches (default: False).

country (str, optional): Country of the station. country_exact (bool, optional): Only exact matches, otherwise

all matches (default: False).

countrycode (str, optional): 2-digit countrycode of the station

(see ISO 3166-1 alpha-2)

state (str, optional): State of the station. state_exact (bool, optional): Only exact matches, otherwise all

matches. (default: False)

language (str, optional): Language of the station. language_exact (bool, optional): Only exact matches, otherwise

all matches. (default: False)

tag (str, optional): Tag of the station. tag_exact (bool, optional): Only exact matches, otherwise all

matches. (default: False)

tag_list (str, optional): A comma-separated list of tag. bitrate_min (int, optional): Minimum of kbps for bitrate field of

stations in result. (default: 0)

bitrate_max (int, optional): Maximum of kbps for bitrate field of

stations in result. (default: 1000000)

order (str, optional): The result list will be sorted by: name,

url, homepage, favicon, tags, country, state, language, votes, codec, bitrate, lastcheckok, lastchecktime, clicktimestamp, clickcount, clicktrend, random

reverse (bool, optional): Reverse the result list if set to true.

(default: false)

offset (int, optional): Starting value of the result list from

the database. For example, if you want to do paging on the server side. (default: 0)

limit (int, optional): Number of returned datarows (stations)

starting with offset (default 100000)

hidebroken (bool, optional): do list/not list broken stations.

Note: Not documented in the “Advanced Station Search”.

returns:

Station.

rtype:

list

See details:

https://de1.api.radio-browser.info/#Advanced_station_search

states(country=None, state=None)[source]#

Lists all states.

Parameters:
  • country (str, optional) – Filter by country. Defaults to None.

  • state (str, optionla) – Filter by state. Defaults to None.

Returns:

States.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_states

async station_by_uuid(stationuuid)[source]#

Radio station by stationuuid.

Parameters:

stationuuid (str) – A globally unique identifier for the station.

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations(**kwargs)[source]#

Lists all radio stations.

Returns:

Stations.

Return type:

list

See details:

https://nl1.api.radio-browser.info/#List_of_all_radio_stations

async stations_by_clicks(limit, **kwargs)[source]#

A list of the stations that are clicked the most.

Parameters:

limit – Number of wanted stations

Returns:

Stations.

Return type:

list

See details:

https://nl1.api.radio-browser.info/#Stations_by_clicks

async stations_by_codec(codec, exact=False, **kwargs)[source]#

Lists all radio stations by codec.

Parameters:
  • codec (str) – The name of the codec.

  • exact (bool) – if the search should search for a station with the exact codec

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_country(country, exact=False, **kwargs)[source]#

Lists all radio stations by country.

Parameters:
  • country (str) – The name of the country.

  • exact (bool) – if the search should search for a station with the exact country

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_countrycode(code, **kwargs)[source]#

Lists all radio stations by country code.

Arguments:#

code (str): Official countrycodes as in ISO 3166-1 alpha-2. exact (bool): if the search should search for a station with the exact code

returns:

Stations.

rtype:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_language(language, exact=False, **kwargs)[source]#

Lists all radio stations by language.

Parameters:
  • language (str) – The name of the language.

  • exact (bool) – if the search should search for a station with the exact language

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_name(name, exact=False, **kwargs)[source]#

Lists all radio stations by name.

Parameters:
  • name (str) – The name of the station.

  • exact (bool) – if the search should search for a station with the exact name

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_state(state, exact=False, **kwargs)[source]#

Lists all radio stations by state.

Parameters:
  • state (str) – The name of the state.

  • exact (bool) – if the search should search for a station with the exact state

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_tag(tag, exact=False, **kwargs)[source]#

Lists all radio stations by tag.

Parameters:
  • tag (str) – The name of the tag.

  • exact (bool) – If set to True, the tag must be exactly the same as the given tag.

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_tag_list(tag_list, **kwargs)[source]#

Lists all radio stations by tag. Must match all tags exactly.

Parameters:

tag_list (list) – A list of names of tags.

Returns:

Stations.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_radio_stations

async stations_by_votes(limit, **kwargs)[source]#

A list of the highest-voted stations.

Parameters:

limit – Number of wanted stations

Returns:

Stations.

Return type:

list

See details:

https://nl1.api.radio-browser.info/#Stations_by_votes

tags(tag=None)[source]#

Lists all tags.

Parameters:

tag (str, optional) – Filter by tag. Defaults to None.

Returns:

Tags.

Return type:

list

See details:

https://de1.api.radio-browser.info/#List_of_tags