[34] Merge branch 'refs/heads/FestiveKyle/plex-overide-verify-ssl' into nightly

This commit is contained in:
meisnate12 2024-03-06 08:53:24 -05:00
commit 1fa23ab411
4 changed files with 14 additions and 1 deletions

View file

@ -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

View file

@ -90,6 +90,9 @@
"optimize": {
"description": "true/false - If 'true', optimizes database on this Plex server",
"type": "boolean"
},
"verify_ssl": {
"type": "boolean"
}
},
"required": [

View file

@ -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"]:

View file

@ -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}")