mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-26 06:20:23 +00:00
sonarr language profile validation
This commit is contained in:
parent
42e81a4f39
commit
1e9c901466
3 changed files with 33 additions and 15 deletions
|
@ -258,7 +258,7 @@ class Config:
|
|||
self.general["sonarr"]["version"] = check_for_attribute(self.data, "version", parent="sonarr", test_list=["v2", "v3"], options=" v2 (For Sonarr 0.2)\n v3 (For Sonarr 3.0)", default="v2")
|
||||
self.general["sonarr"]["quality_profile"] = check_for_attribute(self.data, "quality_profile", parent="sonarr", default_is_none=True)
|
||||
self.general["sonarr"]["root_folder_path"] = check_for_attribute(self.data, "root_folder_path", parent="sonarr", default_is_none=True)
|
||||
self.general["sonarr"]["language_profile_id"] = check_for_attribute(self.data, "language_profile_id", parent="sonarr", default=1)
|
||||
self.general["sonarr"]["language_profile"] = check_for_attribute(self.data, "language_profile", parent="sonarr", default_is_none=True)
|
||||
self.general["sonarr"]["add"] = check_for_attribute(self.data, "add", parent="sonarr", var_type="bool", default=False)
|
||||
self.general["sonarr"]["search"] = check_for_attribute(self.data, "search", parent="sonarr", var_type="bool", default=False)
|
||||
self.general["sonarr"]["season_folder"] = check_for_attribute(self.data, "season_folder", parent="sonarr", var_type="bool", default=True)
|
||||
|
@ -359,7 +359,10 @@ class Config:
|
|||
sonarr_params["version"] = check_for_attribute(lib, "version", parent="sonarr", test_list=["v2", "v3"], options=" v2 (For Sonarr 0.2)\n v3 (For Sonarr 3.0)", default=self.general["sonarr"]["version"], save=False)
|
||||
sonarr_params["quality_profile"] = check_for_attribute(lib, "quality_profile", parent="sonarr", default=self.general["sonarr"]["quality_profile"], req_default=True, save=False)
|
||||
sonarr_params["root_folder_path"] = check_for_attribute(lib, "root_folder_path", parent="sonarr", default=self.general["sonarr"]["root_folder_path"], req_default=True, save=False)
|
||||
sonarr_params["language_profile_id"] = check_for_attribute(lib, "language_profile_id", parent="sonarr", default=self.general["sonarr"]["language_profile_id"], save=False)
|
||||
if self.general["sonarr"]["language_profile"]:
|
||||
sonarr_params["language_profile"] = check_for_attribute(lib, "language_profile", parent="sonarr", default=self.general["sonarr"]["language_profile"], save=False)
|
||||
else:
|
||||
sonarr_params["language_profile"] = check_for_attribute(lib, "language_profile", parent="sonarr", default_is_none=True, save=False)
|
||||
sonarr_params["add"] = check_for_attribute(lib, "add", parent="sonarr", var_type="bool", default=self.general["sonarr"]["add"], save=False)
|
||||
sonarr_params["search"] = check_for_attribute(lib, "search", parent="sonarr", var_type="bool", default=self.general["sonarr"]["search"], save=False)
|
||||
sonarr_params["season_folder"] = check_for_attribute(lib, "season_folder", parent="sonarr", var_type="bool", default=self.general["sonarr"]["season_folder"], save=False)
|
||||
|
|
|
@ -20,7 +20,7 @@ class RadarrAPI:
|
|||
raise Failed("Radarr Error: Unexpected Response Check URL")
|
||||
self.quality_profile_id = None
|
||||
profiles = ""
|
||||
for profile in self.send_get(f"{self.base_url}{'qualityProfile' if params['version'] == 'v3' else 'profile'}"):
|
||||
for profile in self.send_get("qualityProfile" if params["version"] == "v3" else "profile"):
|
||||
if len(profiles) > 0:
|
||||
profiles += ", "
|
||||
profiles += profile["name"]
|
||||
|
@ -47,8 +47,8 @@ class RadarrAPI:
|
|||
if tag:
|
||||
tag_cache = {}
|
||||
for label in tag:
|
||||
self.send_post(f"{self.base_url}tag", {"label": str(label)})
|
||||
for t in self.send_get(f"{self.base_url}tag"):
|
||||
self.send_post("tag", {"label": str(label)})
|
||||
for t in self.send_get("tag"):
|
||||
tag_cache[t["label"]] = t["id"]
|
||||
for label in tag:
|
||||
if label in tag_cache:
|
||||
|
@ -87,7 +87,7 @@ class RadarrAPI:
|
|||
}
|
||||
if tag_nums:
|
||||
url_json["tags"] = tag_nums
|
||||
response = self.send_post(f"{self.base_url}movie", url_json)
|
||||
response = self.send_post("movie", url_json)
|
||||
if response.status_code < 400:
|
||||
logger.info(f"Added to Radarr | {tmdb_id:<6} | {movie.title}")
|
||||
add_count += 1
|
||||
|
@ -101,8 +101,8 @@ class RadarrAPI:
|
|||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000)
|
||||
def send_get(self, url):
|
||||
return requests.get(url, params=self.url_params).json()
|
||||
return requests.get(f"{self.base_url}{url}", params=self.url_params).json()
|
||||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000)
|
||||
def send_post(self, url, url_json):
|
||||
return requests.post(url, json=url_json, params=self.url_params)
|
||||
return requests.post(f"{self.base_url}{url}", json=url_json, params=self.url_params)
|
||||
|
|
|
@ -20,7 +20,7 @@ class SonarrAPI:
|
|||
raise Failed("Sonarr Error: Unexpected Response Check URL")
|
||||
self.quality_profile_id = None
|
||||
profiles = ""
|
||||
for profile in self.send_get(f"{self.base_url}{'qualityProfile' if params['version'] == 'v3' else 'profile'}"):
|
||||
for profile in self.send_get("qualityProfile" if params["version"] == "v3" else "profile"):
|
||||
if len(profiles) > 0:
|
||||
profiles += ", "
|
||||
profiles += profile["name"]
|
||||
|
@ -28,13 +28,28 @@ class SonarrAPI:
|
|||
self.quality_profile_id = profile["id"]
|
||||
if not self.quality_profile_id:
|
||||
raise Failed(f"Sonarr Error: quality_profile: {params['quality_profile']} does not exist in sonarr. Profiles available: {profiles}")
|
||||
|
||||
self.language_profile_id = None
|
||||
if params["version"] == "v3" and params["language_profile"] is not None:
|
||||
profiles = ""
|
||||
for profile in self.send_get("languageProfile"):
|
||||
if len(profiles) > 0:
|
||||
profiles += ", "
|
||||
profiles += profile["name"]
|
||||
if profile["name"] == params["language_profile"]:
|
||||
self.language_profile_id = profile["id"]
|
||||
if not self.quality_profile_id:
|
||||
raise Failed(f"Sonarr Error: language_profile: {params['language_profile']} does not exist in sonarr. Profiles available: {profiles}")
|
||||
|
||||
if self.language_profile_id is None:
|
||||
self.language_profile_id = 1
|
||||
|
||||
self.tvdb = tvdb
|
||||
self.language = language
|
||||
self.url = params["url"]
|
||||
self.version = params["version"]
|
||||
self.token = params["token"]
|
||||
self.root_folder_path = params["root_folder_path"]
|
||||
self.language_profile_id = params["language_profile_id"]
|
||||
self.add = params["add"]
|
||||
self.search = params["search"]
|
||||
self.season_folder = params["season_folder"]
|
||||
|
@ -50,8 +65,8 @@ class SonarrAPI:
|
|||
if tag:
|
||||
tag_cache = {}
|
||||
for label in tag:
|
||||
self.send_post(f"{self.base_url}tag", {"label": str(label)})
|
||||
for t in self.send_get(f"{self.base_url}tag"):
|
||||
self.send_post("tag", {"label": str(label)})
|
||||
for t in self.send_get("tag"):
|
||||
tag_cache[t["label"]] = t["id"]
|
||||
for label in tag:
|
||||
if label in tag_cache:
|
||||
|
@ -81,7 +96,7 @@ class SonarrAPI:
|
|||
}
|
||||
if tag_nums:
|
||||
url_json["tags"] = tag_nums
|
||||
response = self.send_post(f"{self.base_url}series", url_json)
|
||||
response = self.send_post("series", url_json)
|
||||
if response.status_code < 400:
|
||||
logger.info(f"Added to Sonarr | {tvdb_id:<6} | {show.title}")
|
||||
add_count += 1
|
||||
|
@ -95,8 +110,8 @@ class SonarrAPI:
|
|||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000)
|
||||
def send_get(self, url):
|
||||
return requests.get(url, params=self.url_params).json()
|
||||
return requests.get(f"{self.base_url}{url}", params=self.url_params).json()
|
||||
|
||||
@retry(stop_max_attempt_number=6, wait_fixed=10000)
|
||||
def send_post(self, url, url_json):
|
||||
return requests.post(url, json=url_json, params=self.url_params)
|
||||
return requests.post(f"{self.base_url}{url}", json=url_json, params=self.url_params)
|
||||
|
|
Loading…
Reference in a new issue