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
pip install arrapi
Documentation can be found at Read the Docs.
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)
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.
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()
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()
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)
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")
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)
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.
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()
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()
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)
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")
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)