mirror of
https://github.com/mza921/Plex-Auto-Collections
synced 2024-11-14 16:27:22 +00:00
Add support for Radarr v3 API
This commit is contained in:
parent
4ce154d8ec
commit
66ae96298a
2 changed files with 30 additions and 9 deletions
|
@ -26,9 +26,22 @@ class Config:
|
|||
self.data = yaml.load(yml, Loader=yaml.FullLoader)
|
||||
self.collections = self.data['collections']
|
||||
self.plex = self.data['plex']
|
||||
self.tmdb = self.data['tmdb']
|
||||
self.trakt = self.data['trakt']
|
||||
self.radarr = self.data['radarr']
|
||||
# Make 'tmdb' key optional
|
||||
if 'tmdb' in self.data:
|
||||
self.tmdb = self.data['tmdb']
|
||||
else:
|
||||
self.tmdb = {}
|
||||
# Make 'trakt' key optional
|
||||
if 'trakt' in self.data:
|
||||
self.trakt = self.data['trakt']
|
||||
else:
|
||||
self.trakt = {}
|
||||
# Make 'radarr' key optional
|
||||
if 'radarr' in self.data:
|
||||
self.radarr = self.data['radarr']
|
||||
else:
|
||||
self.radarr = {}
|
||||
# Make 'image-server' key optional
|
||||
if 'image-server' in self.data:
|
||||
self.image_server = self.data['image-server']
|
||||
else:
|
||||
|
@ -59,6 +72,11 @@ class Radarr:
|
|||
def __init__(self, config_path):
|
||||
config = Config(config_path).radarr
|
||||
self.url = config['url']
|
||||
# Set 'version' to v2 if not set
|
||||
if 'version' in config:
|
||||
self.version = config['version']
|
||||
else:
|
||||
self.version = "v2"
|
||||
self.token = config['token']
|
||||
self.quality_profile_id = config['quality_profile_id']
|
||||
self.root_folder_path = config['root_folder_path']
|
||||
|
|
|
@ -57,13 +57,16 @@ def add_to_radarr(config_path, missing):
|
|||
}
|
||||
}
|
||||
|
||||
url = config_radarr.url + "/api/movie"
|
||||
if config_radarr.version == "v3":
|
||||
slug = "/api/v3/movie"
|
||||
else:
|
||||
slug = "/api/movie"
|
||||
url = config_radarr.url + slug
|
||||
querystring = {"apikey": "{}".format(config_radarr.token)}
|
||||
|
||||
response = requests.post(url, json=payload, params=querystring)
|
||||
|
||||
try:
|
||||
if response.json()[0]['errorMessage'] == "This movie has already been added":
|
||||
print(tmdb_title + " already added to Radarr")
|
||||
except KeyError:
|
||||
print("+++ " + tmdb_title + " added to Radarr")
|
||||
if response.status_code < 400:
|
||||
print("+++ " + tmdb_title + ": Added to Radarr")
|
||||
else:
|
||||
print("--- " + tmdb_title + ": " + response.json()[0]['errorMessage'])
|
Loading…
Reference in a new issue