mirror of
https://github.com/mza921/Plex-Auto-Collections
synced 2024-11-15 00:37:13 +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.data = yaml.load(yml, Loader=yaml.FullLoader)
|
||||||
self.collections = self.data['collections']
|
self.collections = self.data['collections']
|
||||||
self.plex = self.data['plex']
|
self.plex = self.data['plex']
|
||||||
|
# Make 'tmdb' key optional
|
||||||
|
if 'tmdb' in self.data:
|
||||||
self.tmdb = self.data['tmdb']
|
self.tmdb = self.data['tmdb']
|
||||||
|
else:
|
||||||
|
self.tmdb = {}
|
||||||
|
# Make 'trakt' key optional
|
||||||
|
if 'trakt' in self.data:
|
||||||
self.trakt = self.data['trakt']
|
self.trakt = self.data['trakt']
|
||||||
|
else:
|
||||||
|
self.trakt = {}
|
||||||
|
# Make 'radarr' key optional
|
||||||
|
if 'radarr' in self.data:
|
||||||
self.radarr = self.data['radarr']
|
self.radarr = self.data['radarr']
|
||||||
|
else:
|
||||||
|
self.radarr = {}
|
||||||
|
# Make 'image-server' key optional
|
||||||
if 'image-server' in self.data:
|
if 'image-server' in self.data:
|
||||||
self.image_server = self.data['image-server']
|
self.image_server = self.data['image-server']
|
||||||
else:
|
else:
|
||||||
|
@ -59,6 +72,11 @@ class Radarr:
|
||||||
def __init__(self, config_path):
|
def __init__(self, config_path):
|
||||||
config = Config(config_path).radarr
|
config = Config(config_path).radarr
|
||||||
self.url = config['url']
|
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.token = config['token']
|
||||||
self.quality_profile_id = config['quality_profile_id']
|
self.quality_profile_id = config['quality_profile_id']
|
||||||
self.root_folder_path = config['root_folder_path']
|
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)}
|
querystring = {"apikey": "{}".format(config_radarr.token)}
|
||||||
|
|
||||||
response = requests.post(url, json=payload, params=querystring)
|
response = requests.post(url, json=payload, params=querystring)
|
||||||
|
|
||||||
try:
|
if response.status_code < 400:
|
||||||
if response.json()[0]['errorMessage'] == "This movie has already been added":
|
print("+++ " + tmdb_title + ": Added to Radarr")
|
||||||
print(tmdb_title + " already added to Radarr")
|
else:
|
||||||
except KeyError:
|
print("--- " + tmdb_title + ": " + response.json()[0]['errorMessage'])
|
||||||
print("+++ " + tmdb_title + " added to Radarr")
|
|
Loading…
Reference in a new issue