Skip to content

Commit

Permalink
Check KodiSyncQueue GetPluginSettings endpoint
Browse files Browse the repository at this point in the history
to determine whether the plugin is enabled or not

Fixes #861
  • Loading branch information
oddstr13 committed May 17, 2024
1 parent fbc8a99 commit 4c6b69a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
33 changes: 8 additions & 25 deletions jellyfin_kodi/jellyfin/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,37 +254,20 @@ def get_items_theme_song(self, parent_id):
'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"
]

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
plugin_settings = self._get("Jellyfin.Plugin.KodiSyncQueue/GetPluginSettings") or {}
return plugin_settings.get('IsEnabled')

Check warning on line 265 in jellyfin_kodi/jellyfin/api.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/jellyfin/api.py#L264-L265

Added lines #L264 - L265 were not covered by tests

except requests.RequestException as e:
LOG.warning("Error checking companion installed state: %s", e)
if e.response.status_code == 404:
return False

Check warning on line 270 in jellyfin_kodi/jellyfin/api.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/jellyfin/api.py#L270

Added line #L270 was not covered by tests

return None

Expand Down
2 changes: 1 addition & 1 deletion jellyfin_kodi/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def startup(self):
'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))
Expand Down

0 comments on commit 4c6b69a

Please sign in to comment.