Skip to content

Kometa-Team/ArrAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)