Skip to content

Podcast

Podcast(api, subsonic)

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

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

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

create_podcast_channel(url)

Create a new podcast channel

Parameters:

Name Type Description Default
url str

The URL of the podcast to add.

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/_podcast.py
def create_podcast_channel(self, url: str) -> "Subsonic":
    """Create a new podcast channel

    Args:
        url: The URL of the podcast to add.

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

    self.api.json_request("createPodcastChannel", {"url": url})

    return self.subsonic

delete_podcast_channel(podcast_channel_id)

Delete a podcast channel.

Parameters:

Name Type Description Default
podcast_channel_id str

The ID of the podcast channel 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/_podcast.py
def delete_podcast_channel(self, podcast_channel_id: str) -> "Subsonic":
    """Delete a podcast channel.

    Args:
        podcast_channel_id: The ID of the podcast channel to delete.

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

    self.api.json_request("deletePodcastChannel", {"id": podcast_channel_id})

    return self.subsonic

delete_podcast_episode(podcast_episode_id)

Delete a podcast episode from the server.

Parameters:

Name Type Description Default
podcast_episode_id str

The ID of the podcast episode 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/_podcast.py
def delete_podcast_episode(self, podcast_episode_id: str) -> "Subsonic":
    """Delete a podcast episode from the server.

    Args:
        podcast_episode_id: The ID of the podcast episode to delete.

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

    self.api.json_request("deletePodcastEpisode", {"id": podcast_episode_id})

    return self.subsonic

download_podcast_episode(podcast_episode_id)

Download a podcast episode to the server.

Parameters:

Name Type Description Default
podcast_episode_id str

The ID of the podcast episode to download to the server.

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/_podcast.py
def download_podcast_episode(self, podcast_episode_id: str) -> "Subsonic":
    """Download a podcast episode to the server.

    Args:
        podcast_episode_id: The ID of the podcast episode to download to
            the server.

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

    self.api.json_request("downloadPodcastEpisode", {"id": podcast_episode_id})

    return self.subsonic

get_newest_podcast_episodes(number_max_episodes)

Get all the info about the newest released podcast episodes.

Parameters:

Name Type Description Default
number_max_episodes int

The max number of episodes that the server should return.

required

Returns:

Type Description
list[Episode]

A list that holds all the info about all the newest released episodes.

Source code in .venv/lib/python3.11/site-packages/knuckles/_podcast.py
def get_newest_podcast_episodes(self, number_max_episodes: int) -> list[Episode]:
    """Get all the info about the newest released podcast episodes.

    Args:
        number_max_episodes: The max number of episodes that the server
            should return.

    Returns:
        A list that holds all the info about all the newest released
            episodes.
    """

    response = self.api.json_request(
        "getNewestPodcasts", {"count": number_max_episodes}
    )["newestPodcasts"]["episode"]

    return [Episode(self.subsonic, **episode) for episode in response]

get_podcast_channel(podcast_channel_id, with_episodes=None)

Get all the info about a podcast channel.

Parameters:

Name Type Description Default
podcast_channel_id str

The ID of the podcast channel to get its info.

required
with_episodes bool | None

If the server should also return all the info about each episode of the podcast channel.

None

Returns:

Type Description
Channel

An object that hold all the info about the requested podcast channel.

Source code in .venv/lib/python3.11/site-packages/knuckles/_podcast.py
def get_podcast_channel(
    self, podcast_channel_id: str, with_episodes: bool | None = None
) -> Channel:
    """Get all the info about a podcast channel.

    Args:
        podcast_channel_id: The ID of the podcast channel to get its info.
        with_episodes: If the server should also return all the info
            about each episode of the podcast channel.

    Returns:
        An object that hold all the info about the requested podcast
            channel.
    """

    response = self.api.json_request(
        "getPodcasts", {"id": podcast_channel_id, "includeEpisodes": with_episodes}
    )["podcasts"][0]

    return Channel(self.subsonic, **response)

get_podcast_channels(with_episodes=True)

Get all the info about all the available podcasts channels in the server.

Parameters:

Name Type Description Default
with_episodes bool

If the server should also return all the info about each episode of each podcast channel

True

Returns:

Type Description
list[Channel]

An list that hold all the info about all the available podcasts channels.

Source code in .venv/lib/python3.11/site-packages/knuckles/_podcast.py
def get_podcast_channels(self, with_episodes: bool = True) -> list[Channel]:
    """Get all the info about all the available podcasts channels in the
    server.

    Args:
        with_episodes: If the server should also return all the info
            about each episode of each podcast channel

    Returns:
        An list that hold all the info about all the available podcasts
            channels.
    """

    response = self.api.json_request(
        "getPodcasts", {"includeEpisodes": with_episodes}
    )["podcasts"]

    return [Channel(self.subsonic, **channel) for channel in response]

get_podcast_episode(episode_id)

Get all the info about a podcast episode.

Parameters:

Name Type Description Default
episode_id str

The ID of the podcast episode to get its info.

required

Returns:

Type Description
Episode | None

An object that holds all the info about the requested podcast episode.

Source code in .venv/lib/python3.11/site-packages/knuckles/_podcast.py
def get_podcast_episode(self, episode_id: str) -> Episode | None:
    """Get all the info about a podcast episode.

    Args:
        episode_id: The ID of the podcast episode to get its info.

    Returns:
        An object that holds all the info about the requested podcast
            episode.
    """

    channels = self.get_podcast_channels()

    # Flatten the list of episodes inside the list of channels
    list_of_episodes = [
        episode
        for channel in channels
        if channel.episodes is not None
        for episode in channel.episodes
    ]

    for episode in list_of_episodes:
        if episode.id == episode_id:
            return episode

    return None

refresh_podcasts()

Request the server to search for new podcast episodes.

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/_podcast.py
def refresh_podcasts(self) -> "Subsonic":
    """Request the server to search for new podcast episodes.

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

    self.api.json_request("refreshPodcasts")

    return self.subsonic