Sonarr

Note

An asynchronous version of this client is available as AsyncSonarr. The API is identical, but all methods are coroutines and must be awaited.

class pyarr._sync.sonarr.Sonarr(host: str, api_key: str, port: int = 8989, tls: bool = True, base_path: str = '', request_timeout: int | None = None, api_ver: str | None = None)[source]

Sonarr API client.

Series

class pyarr._sync.sonarr.series.Series(handler: RequestHandler)[source]

Series actions for Sonarr.

get(item_id: int | None = None, tvdb: bool = False, tmdb: bool = False) list[dict[str, Any]] | dict[str, Any][source]

Returns the list of added series or a specific series by ID, TVDB ID, or TMDB ID.

Parameters:
  • item_id (int | None, optional) – ID of the series to return. Defaults to None.

  • tvdb (bool, optional) – Set to true if item_id is the TVDB ID. Defaults to False.

  • tmdb (bool, optional) – Set to true if item_id is the TMDB ID. Defaults to False.

Returns:

List of dictionaries with items or a single dictionary.

Return type:

JsonArray | JsonObject

add(series: dict[str, Any], quality_profile_id: int, language_profile_id: int, root_dir: str, season_folder: bool = True, monitored: bool = True, ignore_episodes_with_files: bool = False, ignore_episodes_without_files: bool = False, search_for_missing_episodes: bool = False) dict[str, Any][source]

Adds a new series to your collection.

Parameters:
  • series (JsonObject) – A series object from lookup().

  • quality_profile_id (int) – Database id for quality profile.

  • language_profile_id (int) – Database id for language profile.

  • root_dir (str) – Root folder location.

  • season_folder (bool, optional) – Create a folder for each season. Defaults to True.

  • monitored (bool, optional) – Monitor this series. Defaults to True.

  • ignore_episodes_with_files (bool, optional) – Ignore any episodes with existing files. Defaults to False.

  • ignore_episodes_without_files (bool, optional) – Ignore any episodes without existing files. Defaults to False.

  • search_for_missing_episodes (bool, optional) – Search for missing episodes to download. Defaults to False.

Returns:

Dictionary of added record.

Return type:

JsonObject

update(data: dict[str, Any]) dict[str, Any][source]

Updates a series in the database.

Parameters:

data (JsonObject) – data to update series.

Returns:

updated series.

Return type:

JsonObject

delete(item_id: int, delete_files: bool = False) bool[source]

Delete a series from the database.

Parameters:
  • item_id (int) – series id.

  • delete_files (bool, optional) – Also delete files associated with the series. Defaults to False.

Returns:

True if series was deleted.

Return type:

bool

lookup(term: str | None = None, item_id: int | None = None) list[dict[str, Any]][source]

Searches for new shows on TheTVDB.com.

Parameters:
  • term (Optional[str], optional) – Series’ Name.

  • item_id (Optional[int], optional) – TVDB ID for series.

Returns:

List of dictionaries with items.

Return type:

JsonArray

Episode

class pyarr._sync.sonarr.episode.Episode(handler: RequestHandler)[source]

Episode actions for Sonarr.

get(item_id: int | None = None, series_id: int | None = None) list[dict[str, Any]] | dict[str, Any][source]

Returns episodes by ID or series ID.

Parameters:
  • item_id (int | None, optional) – ID for Episode. Defaults to None.

  • series_id (int | None, optional) – ID for Series. Defaults to None.

Returns:

List of dictionaries with items or a single dictionary.

Return type:

JsonArray | JsonObject

update(item_id: int, data: dict[str, Any]) dict[str, Any][source]

Update the given episode.

Parameters:
  • item_id (int) – ID of the Episode to be updated.

  • data (JsonObject) – Parameters to update the episode.

Returns:

Dictionary with updated record.

Return type:

JsonObject

monitor(episode_ids: list[int], monitored: bool = True) list[dict[str, Any]][source]

Update episode monitored status.

Parameters:
  • episode_ids (list[int]) – All episode IDs to be updated.

  • monitored (bool, optional) – True or False. Defaults to True.

Returns:

list of dictionaries containing updated records.

Return type:

JsonArray

Episode File

class pyarr._sync.sonarr.episode_file.EpisodeFile(handler: RequestHandler)[source]

Episode file actions for Sonarr.

get(item_id: int | None = None, series_id: int | None = None) list[dict[str, Any]] | dict[str, Any][source]

Returns episode file information.

Parameters:
  • item_id (int | None, optional) – Database id of episode file. Defaults to None.

  • series_id (int | None, optional) – Database id of series. Defaults to None.

Returns:

List of dictionaries with items or a single dictionary.

Return type:

JsonArray | JsonObject

delete(item_id: int) None[source]

Deletes the episode file with corresponding id.

Parameters:

item_id (int) – Database id for episode file.

update_quality(item_id: int, data: dict[str, Any]) dict[str, Any][source]

Updates the quality of the episode file.

Parameters:
  • item_id (int) – Database id for episode file.

  • data (JsonObject) – Data with quality.

Returns:

Dictionary with updated record.

Return type:

JsonObject

Release

class pyarr._sync.sonarr.release.Release(handler: RequestHandler)[source]

Release actions for Sonarr.

get(episode_id: int | None = None) list[dict[str, Any]][source]

Query indexers for latest releases.

Parameters:

episode_id (int | None, optional) – Database id for episode to check. Defaults to None.

Returns:

List of dictionaries with items.

Return type:

JsonArray

add(guid: str, indexer_id: int) dict[str, Any][source]

Adds a previously searched release to the download client.

Parameters:
  • guid (str) – Recently searched result guid.

  • indexer_id (int) – Database id of indexer to use.

Returns:

Dictionary with download release details.

Return type:

JsonObject

push(title: str, download_url: str, protocol: str, publish_date: datetime) list[dict[str, Any]][source]

If the title is wanted, Sonarr will grab it.

Parameters:
  • title (str) – Release name.

  • download_url (str) – .torrent file URL.

  • protocol (str) – β€œUsenet” or β€œTorrent”.

  • publish_date (datetime) – ISO8601 date.

Returns:

List of dictionaries with items.

Return type:

JsonArray

Manual Import

class pyarr._sync.sonarr.manual_import.ManualImport(handler: RequestHandler)[source]

Manual import actions for Sonarr.

get(folder: str, download_id: str | None = None, series_id: int | None = None, filter_existing_files: bool = True, replace_existing_files: bool = True) list[dict[str, Any]][source]

Gets a manual import list.

Parameters:
  • folder (str) – Folder name.

  • download_id (str | None, optional) – Download ID. Defaults to None.

  • series_id (int | None, optional) – Series Database ID. Defaults to None.

  • filter_existing_files (bool, optional) – Filter files. Defaults to True.

  • replace_existing_files (bool, optional) – Replace files. Defaults to True.

Returns:

List of dictionaries with items.

Return type:

JsonArray

update(data: dict[str, Any]) dict[str, Any][source]

Update a manual import.

Parameters:

data (JsonObject) – Data containing changes.

Returns:

Dictionary of updated record.

Return type:

JsonObject