Change improve Emby status check.

By preventing exceptions from wrong type comparison in a fetched response
This commit is contained in:
Prinz23 2023-10-16 06:00:27 +02:00 committed by JackDandy
parent bdfeaa7350
commit 73d1ae56a9

View file

@ -127,15 +127,15 @@ class EmbyNotifier(Notifier):
response = self._request(f'Library/{endpoint}/Updated', cur_host, keys[i], **args) response = self._request(f'Library/{endpoint}/Updated', cur_host, keys[i], **args)
# Emby will initiate a LibraryMonitor path refresh one minute after this success # Emby will initiate a LibraryMonitor path refresh one minute after this success
if 200 <= self.response.get('status_code') < 300 and self.response.get('ok'): if 200 <= (self.response.get('status_code') or 0) < 300 and self.response.get('ok'):
self._log(f'Success: update {mode_to_log} sent to host {cur_host} in a library updated call') self._log(f'Success: update {mode_to_log} sent to host {cur_host} in a library updated call')
continue continue
elif 401 == self.response.get('status_code'): elif 401 == self.response.get('status_code', 0):
self._log_warning(f'Failed to authenticate with {cur_host}') self._log_warning(f'Failed to authenticate with {cur_host}')
elif 404 == self.response.get('status_code'): elif 404 == self.response.get('status_code', 0):
args = dict(post_json={'Updates': [{'Path': '', 'UpdateType': ''}]}) args = dict(post_json={'Updates': [{'Path': '', 'UpdateType': ''}]})
self._request(f'Library/Media/Updated', cur_host, keys[i], **args) self._request(f'Library/Media/Updated', cur_host, keys[i], **args)
if 200 <= self.response.get('status_code') < 300 and self.response.get('ok'): if 200 <= (self.response.get('status_code') or 0) < 300 and self.response.get('ok'):
self._log(f'Success: fallback to sending Library/Media/Updated call' self._log(f'Success: fallback to sending Library/Media/Updated call'
f' to scan all shows at host {cur_host}') f' to scan all shows at host {cur_host}')
continue continue