Client#
PodMe API.
- class podme_api.client.PodMeClient[source]#
Bases:
objectA client for interacting with the PodMe API.
This class provides methods to authenticate, manage user data, and interact with podcasts and episodes through the PodMe service.
-
auth_client:
PodMeAuthClient# The authentication client.
- Type:
auth_client (PodMeAuthClient)
- language = 'no'#
The language setting for the client.
- Type:
- region = 2#
The region setting for the client.
- Type:
-
session:
ClientSession|None= None# The
aiohttp.ClientSessionto use for API requests.- Type:
(ClientSession | None)
- async save_credentials(filename=None)[source]#
Save the current authentication credentials to a file.
- Parameters:
filename (PathLike | None) – The file to save the credentials to. If None, uses the default location.
- Return type:
- async load_credentials(filename=None)[source]#
Load authentication credentials from a file.
- Parameters:
filename (PathLike | None) – The file to load the credentials from. If None, uses the default location.
- Return type:
- async static transcode_file(input_file, output_file=None, transcode_options=None)[source]#
Remux audio file using ffmpeg.
This will basically remux the audio file into another container format (version 1 of the MP4 Base Media format). Most likely this can be solved in better ways, but this will do for now. If the audio is served to clients in the original container (version 5 as of now), they will be very confused about the total duration of the file, for some reason…
- Parameters:
- Return type:
- async download_file(download_url, path, on_progress=None, on_finished=None, transcode=True)[source]#
Download a file from a given URL and save it to the specified path.
- Parameters:
download_url (URL | str) – The URL of the file to download.
path (PathLike | str) – The local path where the file will be saved.
on_progress (Callable[[PodMeDownloadProgressTask, str, int, int], None], optional) – A callback function to report download progress. It should accept the download URL/path, current and total as arguments (current==total means 100%).
on_finished (Callable[[str, str], None], optional) – A callback function to be called when the download is complete. It should accept the download URL and save path as arguments.
transcode (bool, optional) – Whether to transcode the file. Defaults to True.
- Raises:
PodMeApiDownloadError – If there’s an error during the download process.
- Return type:
- async download_files(download_info, on_progress=None, on_finished=None)[source]#
Download multiple files concurrently.
- Parameters:
download_info (list[tuple[URL | str, Path | str]]) – A list of tuples containing the download URL and save path for each file.
on_progress (Callable[[PodMeDownloadProgressTask, str, int, int], None], optional) – A callback function to report download progress. It should accept the download URL/path, current and total as arguments (current==total means 100%).
on_finished (Callable[[str, str], None], optional) – A callback function to be called when the download is complete. It should accept the download URL and save path as arguments.
- async get_episode_download_url(episode)[source]#
Get the download URL for an episode.
- Parameters:
episode (PodMeEpisode | int) – The episode object or episode ID to get the download URL for.
- Returns:
The episode ID and the download URL.
- Return type:
- Raises:
PodMeApiStreamUrlError – If unable to find url from m3u8, or if the url isn’t downloadable.
- async get_episode_download_url_bulk(episodes)[source]#
Get download URLs for a list of episodes.
This method fetches download URLs for multiple episodes concurrently and ensures that only unique episode IDs are included in the result.
- Parameters:
episodes (list[PodMeEpisode | int]) – A list of PodMeEpisode objects or episode IDs for which to fetch download URLs.
- Returns:
A list of tuples, each containing an episode ID and its corresponding download URL. Duplicate episode IDs are removed.
- Return type:
- Raises:
PodMeApiStreamUrlError – If unable to find url from m3u8, or if the url isn’t downloadable.
- async get_categories(region=None)[source]#
Get podcast categories for a specific region.
- Parameters:
region (PodMeRegion | None) – The region to get categories for. If None, uses the client’s default region.
- Return type:
- async get_category(category_id, region=None)[source]#
Get a category by its ID or key.
- Parameters:
region (PodMeRegion, optional) – The region to get the category for. If None, uses the client’s default region.
- Return type:
- async get_category_by_id(category_id, region=None)[source]#
Get a category by its ID.
- Parameters:
category_id (int) – The ID of the category.
region (PodMeRegion, optional) – The region to get the category for. If None, uses the client’s default region.
- Return type:
- async get_category_by_key(category_key, region=None)[source]#
Get a category by its key.
- Parameters:
category_key (str) – The key of the category.
region (PodMeRegion, optional) – The region to get the category for. If None, uses the client’s default region.
- Return type:
- async get_category_page(category, region=None)[source]#
Get the page for a specific category.
- Parameters:
category (PodMeCategory | int | str) – The category, its ID, or its key.
region (PodMeRegion, optional) – The region to get the category page for. If None, uses the client’s default region.
- Return type:
- async get_podcasts_by_category(category, region=None, pages=None, page_size=None)[source]#
Get podcasts for a specific category.
- Parameters:
category (PodMeCategory | int) – The category or its ID.
region (PodMeRegion, optional) – The region to get podcasts for. If None, uses the client’s default region.
pages (int, optional) – The number of pages to retrieve.
page_size (int, optional) – The number of items per page.
- Return type:
- async get_popular_podcasts(podcast_type=None, category=None, pages=None, page_size=None)[source]#
Get popular podcasts.
- Parameters:
podcast_type (int, optional) – The type of podcasts to retrieve.
category (PodMeCategory | str, optional) – The category or category key to filter by.
pages (int, optional) – The number of pages to retrieve.
page_size (int, optional) – The number of items per page.
- Return type:
- async scrobble_episode(episode_id, playback_progress=None, has_completed=False)[source]#
Update the playback progress for an episode.
- async get_podcast_info(podcast_slug)[source]#
Get information about a podcast.
- Parameters:
podcast_slug (str) – The slug of the podcast.
- Return type:
- async get_podcasts_info(podcast_slugs)[source]#
Get information about multiple podcasts.
- Parameters:
- Return type:
- async get_episode_info(episode_id)[source]#
Get information about an episode.
- Parameters:
episode_id (int) – The ID of the episode.
- Return type:
- async get_episodes_info(episode_ids)[source]#
Get information about multiple episodes.
- Parameters:
- Return type:
- async search_podcast(search, pages=None, page_size=None)[source]#
Search for podcasts.
- Parameters:
- Return type:
- async get_episode_list(podcast_slug)[source]#
Get the full list of episodes for a podcast.
- Parameters:
podcast_slug (str) – The slug of the podcast.
- Return type:
- async get_latest_episodes(podcast_slug, episodes_limit=20)[source]#
Get the latest episodes for a podcast.
- Parameters:
- Return type:
- async check_stream_url(stream_url)[source]#
Check if a stream URL is downloadable.
- Parameters:
stream_url (URL | str) – The URL to check.
- Return type:
- Returns:
The content length and content type if the URL is downloadable, None otherwise.
- async resolve_stream_url(stream_url)[source]#
Check if a stream URL is downloadable.
- Parameters:
stream_url (URL | str) – The URL to check.
- Return type:
- Returns:
The content length and content type if the URL is downloadable, None otherwise.
- Raises:
PodMeApiStreamUrlError – If unable to find url from m3u8, or if the url isn’t downloadable.
-
auth_client: