diff --git a/config/config.yml.template b/config/config.yml.template index 86590520..ac4a798c 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -89,6 +89,7 @@ plex: # Can be individually specified per library as clean_bundles: false empty_trash: false optimize: false + verify_ssl: true tmdb: # REQUIRED for the script to run apikey: ################################ language: en diff --git a/json-schema/config-schema.json b/json-schema/config-schema.json index c2c968cc..5800764b 100644 --- a/json-schema/config-schema.json +++ b/json-schema/config-schema.json @@ -90,6 +90,9 @@ "optimize": { "description": "true/false - If 'true', optimizes database on this Plex server", "type": "boolean" + }, + "verify_ssl": { + "type": "boolean" } }, "required": [ diff --git a/modules/config.py b/modules/config.py index cf6a9376..be0cc2ae 100644 --- a/modules/config.py +++ b/modules/config.py @@ -739,6 +739,7 @@ class ConfigFile: "url": check_for_attribute(self.data, "url", parent="plex", var_type="url", default_is_none=True), "token": check_for_attribute(self.data, "token", parent="plex", default_is_none=True), "timeout": check_for_attribute(self.data, "timeout", parent="plex", var_type="int", default=60), + "verify_ssl": check_for_attribute(self.data, "verify_ssl", parent="plex", var_type="bool", default=True), "db_cache": check_for_attribute(self.data, "db_cache", parent="plex", var_type="int", default_is_none=True) } for attr in ["clean_bundles", "empty_trash", "optimize"]: @@ -1127,6 +1128,7 @@ class ConfigFile: "url": check_for_attribute(lib, "url", parent="plex", var_type="url", default=self.general["plex"]["url"], req_default=True, save=False), "token": check_for_attribute(lib, "token", parent="plex", default=self.general["plex"]["token"], req_default=True, save=False), "timeout": check_for_attribute(lib, "timeout", parent="plex", var_type="int", default=self.general["plex"]["timeout"], save=False), + "verify_ssl": check_for_attribute(lib, "verify_ssl", parent="plex", var_type="bool", default=self.general["plex"]["verify_ssl"], save=False), "db_cache": check_for_attribute(lib, "db_cache", parent="plex", var_type="int", default=self.general["plex"]["db_cache"], default_is_none=True, save=False) } for attr in ["clean_bundles", "empty_trash", "optimize"]: diff --git a/modules/plex.py b/modules/plex.py index f6922cb0..fb19bbe9 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -435,12 +435,19 @@ class Plex(Library): super().__init__(config, params) self.plex = params["plex"] self.url = self.plex["url"] + self.plex["session"] = self.config.session + if self.plex.get("verify_ssl") is False and self.config.general["verify_ssl"] is True: + logger.debug("Overriding verify_ssl to False for Plex connection") + self.plex["session"] = requests.Session() + self.plex["session"].verify = False + import urllib3 + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) self.token = self.plex["token"] self.timeout = self.plex["timeout"] logger.secret(self.url) logger.secret(self.token) try: - self.PlexServer = PlexServer(baseurl=self.url, token=self.token, session=self.config.session, timeout=self.timeout) + self.PlexServer = PlexServer(baseurl=self.url, token=self.token, session=self.plex["session"], timeout=self.timeout) plexapi.server.TIMEOUT = self.timeout os.environ["PLEXAPI_PLEXAPI_TIMEOUT"] = str(self.timeout) logger.info(f"Connected to server {self.PlexServer.friendlyName} version {self.PlexServer.version}")