mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
Companion: check list of installed plugins
instead of only poking the ServerDate plugin endpoint
This commit is contained in:
parent
51d9a4e1cc
commit
16db25e876
2 changed files with 36 additions and 14 deletions
|
@ -258,11 +258,37 @@ class API(object):
|
||||||
return self._get("Plugins")
|
return self._get("Plugins")
|
||||||
|
|
||||||
def check_companion_installed(self):
|
def check_companion_installed(self):
|
||||||
|
"""
|
||||||
|
None = Unknown
|
||||||
|
True = Installed, but possibly not loaded right now
|
||||||
|
False = Not installed, scheduled for uninstalling or disabled
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
self._get("Jellyfin.Plugin.KodiSyncQueue/GetServerDateTime")
|
res = self.get_plugins() # type: requests.Response
|
||||||
return True
|
if res.ok:
|
||||||
except Exception:
|
kodi_sync_queue = [
|
||||||
return False
|
x
|
||||||
|
for x in res.json()
|
||||||
|
if x.get("Id") == "771e19d653854cafb35c28a0e865cf63"
|
||||||
|
]
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def get_seasons(self, show_id):
|
def get_seasons(self, show_id):
|
||||||
return self.shows("/%s/Seasons" % show_id, params={
|
return self.shows("/%s/Seasons" % show_id, params={
|
||||||
|
|
|
@ -343,8 +343,8 @@ class Library(threading.Thread):
|
||||||
if settings('SyncInstallRunDone.bool') and settings(
|
if settings('SyncInstallRunDone.bool') and settings(
|
||||||
'kodiCompanion.bool'
|
'kodiCompanion.bool'
|
||||||
):
|
):
|
||||||
|
# None == Unknown
|
||||||
if self.server.jellyfin.check_companion_installed():
|
if self.server.jellyfin.check_companion_installed() is not False:
|
||||||
|
|
||||||
if not self.fast_sync():
|
if not self.fast_sync():
|
||||||
dialog("ok", "{jellyfin}", translate(33128))
|
dialog("ok", "{jellyfin}", translate(33128))
|
||||||
|
@ -353,8 +353,11 @@ class Library(threading.Thread):
|
||||||
|
|
||||||
LOG.info("--<[ retrieve changes ]")
|
LOG.info("--<[ retrieve changes ]")
|
||||||
|
|
||||||
|
# is False
|
||||||
else:
|
else:
|
||||||
raise LibraryException('CompanionMissing')
|
dialog("ok", "{jellyfin}", translate(33099))
|
||||||
|
settings("kodiCompanion.bool", False)
|
||||||
|
return True
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except LibraryException as error:
|
except LibraryException as error:
|
||||||
|
@ -370,13 +373,6 @@ class Library(threading.Thread):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif error.status == 'CompanionMissing':
|
|
||||||
|
|
||||||
dialog("ok", "{jellyfin}", translate(33099))
|
|
||||||
settings('kodiCompanion.bool', False)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue