Skip to main content

Python wrapper for Radarr and Sonarr APIs:

Project description

ArrAPI

GitHub release (latest by date) Build Testing GitHub commits since latest release (by date) for a branch PyPI Downloads

Wiki Discord Reddit GitHub Sponsors Sponsor or Donate

Overview

Unofficial Python bindings for the Sonarr and Radarr APIs. The goal is to make interaction with the API as easy as possible while emulating the Web Client as much as possible

Installation & Documentation

pip install arrapi

Documentation can be found at Read the Docs.

Connecting to Sonarr

Getting a SonarrAPI Instance

To connect to a Sonarr application you have to use the SonarrAPI object and provide it with the baseurl and apikey parameters.

The apikey can be found by going to Settings > General > Security > API Key

from arrapi import SonarrAPI

baseurl = "http://192.168.1.12:8989"
apikey = "0010843563404748808d3fc9c562c05e"

sonarr = SonarrAPI(baseurl, apikey)

Using the SonarrAPI Instance

Once you have a SonarrAPI instance you can use it to interact with the application.

To add, edit, or delete a singular Series you must first find the Series object.

Find a Series Object

There are three ways to find a Series object.

You can get a Series object using get_series and giving it a Sonarr Series ID or TVDb ID.

series = sonarr.get_series(tvdb_id=121361)

You can get a List of Series objects using search_series and giving it a search term.

search = sonarr.search_series("Game of Thrones")

You can get a List of all Series objects in Sonarr using all_series.

all_series = sonarr.all_series()

Using a Series Object

To add a series to Sonarr use add.

series.add("/shows/", "HD-1080p", "English")

To edit a series in Sonarr use edit.

series.edit(tags=["hd"])

To delete a series in Sonarr use delete.

series.delete()

Perform Operations on Multiple Series

To add multiple Series to Sonarr use add_multiple_series with the Series’ TVDb IDs.

series_ids = [83268, 283468, 385376]
added, exists, invalid = sonarr.add_multiple_series(series_ids, "/shows/", "HD-1080p", "English")

To edit multiple Series in Sonarr use edit_multiple_series with the Series’ TVDb IDs.

series_ids = [83268, 283468, 385376]
edited, not_exist = sonarr.edit_multiple_series(series_ids, monitor=False)

To delete multiple Series in Sonarr use delete_multiple_series with the Series’ TVDb IDs.

series_ids = [83268, 283468, 385376]
not_exist = sonarr.delete_multiple_series(series_ids)

Respect Sonarr List Exclusions

To respect Sonarr’s List Exclusions, before running add or add_multiple_series you can use sonarr_exclusions like so.

series_ids = [83268, 283468, 385376]
sonarr.respect_list_exclusions_when_adding()
added, exists, invalid = sonarr.add_multiple_series(series_ids, "/shows/", "HD-1080p", "English")

Connecting to Radarr

Getting a RadarrAPI Instance

To connect to a Radarr application you have to use the RadarrAPI object and provide it with the baseurl and apikey parameters.

The apikey can be found by going to Settings > General > Security > API Key

from arrapi import RadarrAPI

baseurl = "http://192.168.1.12:8989"
apikey = "0010843563404748808d3fc9c562c05e"

radarr = RadarrAPI(baseurl, apikey)

Using the RadarrAPI Instance

Once you have a RadarrAPI instance you can use it to interact with the application.

To add, edit, or delete a singular Movie you must first find the Movie object.

Find a Movie Object

There are three ways to find a Movie object.

You can get a Movie object using get_movie and giving it a Radarr Movie ID or TVDb ID.

movie = radarr.get_movie(tmdb_id=121361)

You can get a List of Movie objects using search_movies and giving it a search term.

search = radarr.search_movies("The Lord of the Rings: The Return of the King")

You can get a List of all Movie objects in Radarr using all_movies.

all_movies = radarr.all_movies()

Using a Movie Object

To add a movie to Radarr use add.

movie.add("/movies/", "HD-1080p")

To edit a movie in Radarr use edit.

movie.edit(tags=["hd"])

To delete a movie in Radarr use delete.

movie.delete()

Perform Operations on Multiple Movie

To add multiple Movies to Radarr use add_multiple_movies with the Movie’s TMDb IDs.

movie_ids = [11, 1891, 1892, 1893, 1894, 1895]
added, exists, invalid = radarr.add_multiple_movies(movie_ids, "/movies/", "HD-1080p")

To edit multiple Movies in Radarr use edit_multiple_movies with the Movie’s TMDb IDs.

movie_ids = [11, 1891, 1892, 1893, 1894, 1895]
edited, not_exist = radarr.edit_multiple_movies(movie_ids, monitor=False)

To delete multiple Movies in Radarr use delete_multiple_movies with the Movie’s TMDb IDs.

movie_ids = [11, 1891, 1892, 1893, 1894, 1895]
not_exist = radarr.delete_multiple_movies(movie_ids)

Respect Radarr List Exclusions

To respect Radarr’s List Exclusions, before running add or add_multiple_movies you can use radarr_exclusions like so.

movie_ids = [11, 1891, 1892, 1893, 1894, 1895]
radarr.respect_list_exclusions_when_adding()
added, exists, invalid = radarr.add_multiple_movies(movie_ids, "/movies/", "HD-1080p")

Usage Examples

Example 1: List all series in Sonarr.

series = sonarr.all_series()
for show in series:
    print(show.title)

Example 2: Search for a movie and add it to Radarr by name.

search = radarr.search_movies("The Lord of the Rings: The Return of the King")
if search:
    search[0].add("/movies/", "HD-1080p")

Example 3: Make every series in Sonarr Unmonitored.

edited, not_exist = sonarr.edit_multiple_series(sonarr.all_series(), monitor=False)

Example 4: Get all Quality Profiles Available.

for qp in sonarr.quality_profile():
    print(qp.name)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arrapi-1.4.13.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

arrapi-1.4.13-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file arrapi-1.4.13.tar.gz.

File metadata

  • Download URL: arrapi-1.4.13.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for arrapi-1.4.13.tar.gz
Algorithm Hash digest
SHA256 d15da5722d674649067e9597318ee91e5d5363039dad4e499785c0be6fd42271
MD5 81864bd8c57e8ceaaf42ed72ebce7305
BLAKE2b-256 06ff435e09492ebfd6894e1ff0d43ee56cc30aeece9c4cee1b5654f06dac5436

See more details on using hashes here.

File details

Details for the file arrapi-1.4.13-py3-none-any.whl.

File metadata

  • Download URL: arrapi-1.4.13-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for arrapi-1.4.13-py3-none-any.whl
Algorithm Hash digest
SHA256 d2f2a37d3334a69fa1e5405359d087822a36f0d1081b2c16878f4d0a283205d1
MD5 b6f47eec1b61bef24bb7791e1be26979
BLAKE2b-256 d1cebf69a8a4ca3bd45ba53415759bce13442bc38065c798de2eda1aea4bb9e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page