Some checks failed
Build JellyCon / build (py2) (push) Has been cancelled
Build JellyCon / build (py3) (push) Has been cancelled
CodeQL Analysis / analyze (python, 3.9) (push) Has been cancelled
Release Drafter / Update release draft (push) Has been cancelled
Test JellyCon / test (3.9) (push) Has been cancelled
Instead of setting addon variables to None (which causes issues), fix the root cause by removing unnecessary module-level initialization: - Remove module-level user_details loading in functions.py - Load user_details locally in functions where actually needed - Wrap remaining module-level addon access in try/except in: - service.py (log_timing_data) - default.py (log_timing_data) - kodi_utils.py (addon variable) - functions.py (__addon__ and related variables) This prevents crashes during installation/update while avoiding None-related issues during normal operation.
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
from __future__ import (
|
|
division, absolute_import, print_function, unicode_literals
|
|
)
|
|
|
|
import sys
|
|
|
|
import xbmcgui
|
|
import xbmcplugin
|
|
import xbmcaddon
|
|
|
|
from .lazylogger import LazyLogger
|
|
|
|
log = LazyLogger(__name__)
|
|
try:
|
|
addon = xbmcaddon.Addon()
|
|
except Exception:
|
|
# During installation/update, addon might not be fully registered yet
|
|
addon = None
|
|
|
|
|
|
class HomeWindow:
|
|
"""
|
|
xbmcgui.Window(10000) with add-on id prefixed to keys
|
|
"""
|
|
|
|
def __init__(self):
|
|
self.id_string = 'plugin.video.jellycon-%s'
|
|
self.window = xbmcgui.Window(10000)
|
|
|
|
def get_property(self, key):
|
|
key = self.id_string % key
|
|
value = self.window.getProperty(key)
|
|
return value
|
|
|
|
def set_property(self, key, value):
|
|
key = self.id_string % key
|
|
self.window.setProperty(key, value)
|
|
|
|
def clear_property(self, key):
|
|
key = self.id_string % key
|
|
self.window.clearProperty(key)
|
|
|
|
|
|
def add_menu_directory_item(label, path, folder=True, art=None, properties=None):
|
|
li = xbmcgui.ListItem(label, path=path, offscreen=True)
|
|
if art is None:
|
|
art = {}
|
|
art["thumb"] = addon.getAddonInfo('icon')
|
|
if properties is not None:
|
|
li.setProperties(properties)
|
|
li.setArt(art)
|
|
|
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=folder)
|