Merge pull request #862 from oddstr13/pr-server-plugin-enabled-1

Check for KodiSyncQueue GetPluginSettings endpoint
This commit is contained in:
mcarlton00 2024-05-18 07:43:01 -04:00 committed by GitHub
commit 1dcd4b70c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 25 deletions

View file

@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import warnings
#################################################################################################
class HTTPException(Exception):
# Jellyfin HTTP exception
def __init__(self, status, message):
warnings.warn(f'{self.__class__.__name__} will be deprecated.', DeprecationWarning, stacklevel=2)
self.status = status
self.message = message

View file

@ -6,6 +6,7 @@ import json
import requests
from six import ensure_str
from ..helper.exceptions import HTTPException
from ..helper.utils import settings
from ..helper import LazyLogger
@ -254,37 +255,24 @@ class API(object):
'ParentId': parent_id
})
def get_plugins(self):
return self._get("Plugins")
def check_companion_installed(self):
def check_companion_enabled(self):
"""
True = Enabled
False = Not enabled
None = Unknown
True = Installed, but possibly not loaded right now
False = Not installed, scheduled for uninstalling or disabled
"""
try:
kodi_sync_queue = [
x
for x in self.get_plugins()
if x.get("Id") == "771e19d653854cafb35c28a0e865cf63"
]
plugin_settings = self._get("Jellyfin.Plugin.KodiSyncQueue/GetPluginSettings") or {}
return plugin_settings.get('IsEnabled')
LOG.debug("KodiSyncQueue Plugins result: %s", kodi_sync_queue)
kodi_sync_queue_filtered = [
x
for x in kodi_sync_queue
if x.get("Status")
in ["Active", "Restart", "Malfunctioned", "NotSupported"]
]
if kodi_sync_queue_filtered:
return True
else:
return False
except requests.RequestException as e:
LOG.warning("Error checking companion installed state: %s", e)
if e.response.status_code == 404:
return False
except HTTPException as e:
LOG.warning("Error checking companion installed state: %s", e)
if e.status == 404:
return False
return None

View file

@ -353,7 +353,7 @@ class Library(threading.Thread):
'kodiCompanion.bool'
):
# None == Unknown
if self.server.jellyfin.check_companion_installed() is not False:
if self.server.jellyfin.check_companion_enabled() is not False:
if not self.fast_sync():
dialog("ok", "{jellyfin}", translate(33128))