From 69e470525ba88abda7c4c5a3e633f8486f88d06b Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 21 Feb 2021 20:56:31 -0500 Subject: [PATCH] add plex_timeout --- config/config.yml.template | 1 + modules/config.py | 5 ++++- modules/plex.py | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/config.yml.template b/config/config.yml.template index ab29f74a..beea6805 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -19,6 +19,7 @@ settings: # Can be individually specified plex: # Can be individually specified per library as well url: http://192.168.1.12:32400 token: #################### + timeout: 60 tmdb: apikey: ################################ language: en diff --git a/modules/config.py b/modules/config.py index e38e7b0a..956ef89a 100644 --- a/modules/config.py +++ b/modules/config.py @@ -91,7 +91,7 @@ class Config: message = "{} not found".format(text) if parent and save is True: new_config, ind, bsi = yaml.util.load_yaml_guess_indent(open(self.config_path)) - endline = "\n| {} sub-attribute {} added to config".format(parent, attribute) + endline = "\n{} sub-attribute {} added to config".format(parent, attribute) if parent not in new_config: new_config = {parent: {attribute: default}} elif not new_config[parent]: new_config[parent] = {attribute: default} elif attribute not in new_config[parent]: new_config[parent][attribute] = default @@ -214,6 +214,7 @@ class Config: self.general["plex"] = {} self.general["plex"]["url"] = check_for_attribute(self.data, "url", parent="plex", default_is_none=True) self.general["plex"]["token"] = check_for_attribute(self.data, "token", parent="plex", default_is_none=True) + self.general["plex"]["timeout"] = check_for_attribute(self.data, "timeout", parent="plex", var_type="int", default=60) self.general["radarr"] = {} self.general["radarr"]["url"] = check_for_attribute(self.data, "url", parent="radarr", default_is_none=True) @@ -269,6 +270,7 @@ class Config: params["plex"] = {} params["plex"]["url"] = check_for_attribute(libs[lib], "url", parent="plex", default=self.general["plex"]["url"], req_default=True, save=False) params["plex"]["token"] = check_for_attribute(libs[lib], "token", parent="plex", default=self.general["plex"]["token"], req_default=True, save=False) + params["plex"]["timeout"] = check_for_attribute(libs[lib], "timeout", parent="plex", var_type="int", default=self.general["plex"]["timeout"], save=False) library = PlexAPI(params, self.TMDb, self.TVDb) logger.info("{} Library Connection Successful".format(params["name"])) except Failed as e: @@ -334,6 +336,7 @@ class Config: def update_libraries(self, test, requested_collections): for library in self.libraries: + os.environ["PLEXAPI_PLEXAPI_TIMEOUT"] = str(library.timeout) logger.info("") util.seperator("{} Library".format(library.name)) try: library.update_metadata(self.TMDb, test) diff --git a/modules/plex.py b/modules/plex.py index 21cab302..99792fd8 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -13,7 +13,7 @@ logger = logging.getLogger("Plex Meta Manager") class PlexAPI: def __init__(self, params, TMDb, TVDb): - try: self.PlexServer = PlexServer(params["plex"]["url"], params["plex"]["token"], timeout=600) + try: self.PlexServer = PlexServer(params["plex"]["url"], params["plex"]["token"], timeout=params["plex"]["timeout"]) except Unauthorized: raise Failed("Plex Error: Plex token is invalid") except ValueError as e: raise Failed("Plex Error: {}".format(e)) except requests.exceptions.ConnectionError as e: @@ -60,6 +60,7 @@ class PlexAPI: self.show_missing = params["show_missing"] self.save_missing = params["save_missing"] self.plex = params["plex"] + self.timeout = params["plex"]["timeout"] self.missing = {} def add_Radarr(self, Radarr): @@ -71,8 +72,6 @@ class PlexAPI: def add_Tautulli(self, Tautulli): self.Tautulli = Tautulli - - @retry(stop_max_attempt_number=6, wait_fixed=10000) def search(self, title, libtype=None, year=None): if libtype is not None and year is not None: return self.Plex.search(title=title, year=year, libtype=libtype)