diff --git a/config/config.yml.template b/config/config.yml.template index 7735c9c3..d522eced 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 ee53221e..bedf96c4 100644 --- a/json-schema/config-schema.json +++ b/json-schema/config-schema.json @@ -86,6 +86,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 23cc69c4..4eaf5088 100644 --- a/modules/config.py +++ b/modules/config.py @@ -719,6 +719,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), "clean_bundles": check_for_attribute(self.data, "clean_bundles", parent="plex", var_type="bool", default=False), "empty_trash": check_for_attribute(self.data, "empty_trash", parent="plex", var_type="bool", default=False), @@ -1071,6 +1072,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), "clean_bundles": check_for_attribute(lib, "clean_bundles", parent="plex", var_type="bool", default=self.general["plex"]["clean_bundles"], save=False), "empty_trash": check_for_attribute(lib, "empty_trash", parent="plex", var_type="bool", default=self.general["plex"]["empty_trash"], save=False), diff --git a/modules/plex.py b/modules/plex.py index e9141c0e..f1533cbf 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}")