Skip to content

Internet Radio

InternetRadio(api, subsonic)

Class that contains all the methods needed to interact with the internet radio endpoints in the Subsonic API.

Source code in .venv/lib/python3.11/site-packages/knuckles/_internet_radio.py
def __init__(self, api: Api, subsonic: "Subsonic") -> None:
    self.api = api

    # Only to pass it to the models
    self.subsonic = subsonic

create_internet_radio_station(stream_url, name, homepage_url=None)

Create a new internet radio station.

Parameters:

Name Type Description Default
stream_url str

The URL of the stream to be added to the internet radio station.

required
name str

The name of the new created internet radio station.

required
homepage_url str | None

An URL for the homepage of the internet radio station.

None

Returns:

Type Description
Subsonic

An object that holds all the data about the new created internet radio station.

Source code in .venv/lib/python3.11/site-packages/knuckles/_internet_radio.py
def create_internet_radio_station(
    self, stream_url: str, name: str, homepage_url: str | None = None
) -> "Subsonic":
    """Create a new internet radio station.

    Args:
        stream_url: The URL of the stream to be added to the
            internet radio station.
        name: The name of the new created internet radio station.
        homepage_url: An URL for the homepage of the internet
            radio station.

    Returns:
        An object that holds all the data about the new created
            internet radio station.
    """

    self.api.json_request(
        "createInternetRadioStation",
        {"streamUrl": stream_url, "name": name, "homepageUrl": homepage_url},
    )

    return self.subsonic

delete_internet_radio_station(internet_radio_station_id)

Delete an internet radio station.

Parameters:

Name Type Description Default
internet_radio_station_id str

The ID of the internet radio station to delete.

required

Returns:

Type Description
Subsonic

The Subsonic object where this method was called to allow method chaining.

Source code in .venv/lib/python3.11/site-packages/knuckles/_internet_radio.py
def delete_internet_radio_station(
    self, internet_radio_station_id: str
) -> "Subsonic":
    """Delete an internet radio station.

    Args:
        internet_radio_station_id: The ID of the internet radio station
            to delete.

    Returns:
        The Subsonic object where this method was called to allow
            method chaining.
    """
    self.api.json_request(
        "deleteInternetRadioStation", {"id": internet_radio_station_id}
    )

    return self.subsonic

get_internet_radio_station(internet_radio_station_id)

Get all the info related with a internet radio station.

Parameters:

Name Type Description Default
internet_radio_station_id str

The ID of the internet radio station to get its info.

required

Returns:

Type Description
InternetRadioStation | None

An object that contains all the info about the requested internet radio station.

Source code in .venv/lib/python3.11/site-packages/knuckles/_internet_radio.py
def get_internet_radio_station(
    self, internet_radio_station_id: str
) -> InternetRadioStation | None:
    """Get all the info related with a internet radio station.

    Args:
        internet_radio_station_id: The ID of the internet radio station
            to get its info.

    Returns:
        An object that contains all the info about the requested
            internet radio station.
    """

    stations = self.get_internet_radio_stations()

    for station in stations:
        if station.id == internet_radio_station_id:
            return station

    return None

get_internet_radio_stations()

Get all the internet radio stations available in the server.

Returns:

Type Description
list[InternetRadioStation]

A list with all the reported internet radio stations.

Source code in .venv/lib/python3.11/site-packages/knuckles/_internet_radio.py
def get_internet_radio_stations(
    self,
) -> list[InternetRadioStation]:
    """Get all the internet radio stations available in the server.

    Returns:
        A list with all the reported internet radio stations.
    """

    response = self.api.json_request("getInternetRadioStations")[
        "internetRadioStations"
    ]["internetRadioStation"]

    return [InternetRadioStation(self.subsonic, **station) for station in response]

update_internet_radio_station(internet_radio_station_id, stream_url, name, homepage_url=None)

Update the data of an internet radio station.

Parameters:

Name Type Description Default
internet_radio_station_id str

The ID of the internet radio station to edit its data.

required
stream_url str

A new stream URL for the internet radio station.

required
name str

a new name for the internet radio station.

required
homepage_url str | None

A new homepage URL for the internet radio station.

None

Returns:

Type Description
Subsonic

An object that holds all the data about the new updated internet radio station.

Source code in .venv/lib/python3.11/site-packages/knuckles/_internet_radio.py
def update_internet_radio_station(
    self,
    internet_radio_station_id: str,
    stream_url: str,
    name: str,
    homepage_url: str | None = None,
) -> "Subsonic":
    """Update the data of an internet radio station.

    Args:
        internet_radio_station_id: The ID of the internet radio station
            to edit its data.
        stream_url: A new stream URL for the internet radio station.
        name: a new name for the internet radio station.
        homepage_url: A new homepage URL for the internet radio
            station.

    Returns:
        An object that holds all the data about the new updated
            internet radio station.
    """
    self.api.json_request(
        "updateInternetRadioStation",
        {
            "id": internet_radio_station_id,
            "streamUrl": stream_url,
            "name": name,
            "homepageUrl": homepage_url,
        },
    )

    return self.subsonic