Only hide warnings when using https

When not verifying certificates and using `https` we want to hide warnings about the certificate.

Otherwise, we want to not hide anything.
This commit is contained in:
tcely 2025-04-10 19:01:03 -04:00 committed by GitHub
parent d41acf40d0
commit 580a77a5c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -90,15 +90,14 @@ class PlexMediaServer(MediaServer):
def make_request(self, uri='/', /, *, headers={}, params={}): def make_request(self, uri='/', /, *, headers={}, params={}):
url, kwargs = self.make_request_args(uri=uri, headers=headers, token_param='X-Plex-Token', params=params) url, kwargs = self.make_request_args(uri=uri, headers=headers, token_param='X-Plex-Token', params=params)
log.debug(f'[plex media server] Making HTTP GET request to: {url}') log.debug(f'[plex media server] Making HTTP GET request to: {url}')
if kwargs['verify']: if self.object.use_https and not kwargs['verify']:
return requests.get(url, **kwargs)
else:
# If not validating SSL, given this is likely going to be for an internal # If not validating SSL, given this is likely going to be for an internal
# or private network, that Plex issues certs *.hash.plex.direct and that # or private network, that Plex issues certs *.hash.plex.direct and that
# the warning won't ever been sensibly seen in the HTTPS logs, hide it # the warning won't ever been sensibly seen in the HTTPS logs, hide it
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
return requests.get(url, **kwargs) return requests.get(url, **kwargs)
return requests.get(url, **kwargs)
def validate(self): def validate(self):
''' '''
@ -229,6 +228,16 @@ class JellyfinMediaServer(MediaServer):
}) })
log.debug(f'[jellyfin media server] Making HTTP {method} request to: {url}') log.debug(f'[jellyfin media server] Making HTTP {method} request to: {url}')
if self.object.use_https and not kwargs['verify']:
# not verifying certificates
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return requests.request(
method, url,
data=data,
json=json,
**kwargs,
)
return requests.request( return requests.request(
method, url, method, url,
data=data, data=data,