Skip to main content

A lightweight Python library for Radarr and Sonarr API.

Project description

ArrAPI

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

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.2.1.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

arrapi-1.2.1-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

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