mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Update window property
If .json in property name, it will automatically apply json.loads/dumps. This is to avoid importing json in every files.
This commit is contained in:
parent
360d69146d
commit
33ba485b0b
4 changed files with 14 additions and 10 deletions
|
@ -49,7 +49,7 @@ class DownloadUtils(object):
|
|||
info[key] = kwargs[key]
|
||||
|
||||
self.session.update(info)
|
||||
window('emby_server.json', value=json.dumps(self.session))
|
||||
window('emby_server.json', value=self.session)
|
||||
|
||||
log.debug("Set info for server %s: %s", self.session['ServerId'], self.session)
|
||||
|
||||
|
@ -66,7 +66,7 @@ class DownloadUtils(object):
|
|||
if s == server_id:
|
||||
s.update(info)
|
||||
# Set window prop
|
||||
self._set_server_properties(server_id, server['Name'], json.dumps(info))
|
||||
self._set_server_properties(server_id, server['Name'], info)
|
||||
log.info("updating %s to available servers: %s", server_id, self.servers)
|
||||
break
|
||||
else:
|
||||
|
@ -351,7 +351,7 @@ class DownloadUtils(object):
|
|||
server = window('emby_server%s.json' % server_id)
|
||||
|
||||
if server:
|
||||
info.update(json.loads(server))
|
||||
info.update(server)
|
||||
|
||||
return info
|
||||
|
||||
|
|
|
@ -98,9 +98,8 @@ def doMainListing():
|
|||
|
||||
'''
|
||||
TODO: Create plugin listing for servers
|
||||
servers = window('emby_servers')
|
||||
servers = window('emby_servers.json')
|
||||
if servers:
|
||||
servers = json.loads(servers)
|
||||
for server in servers:
|
||||
log.info(window('emby_server%s.name' % server))
|
||||
addDirectoryItem(window('emby_server%s.name' % server), "plugin://plugin.video.emby/?mode=%s" % server)'''
|
||||
|
|
|
@ -249,7 +249,7 @@ class UserClient(threading.Thread):
|
|||
|
||||
# Set properties
|
||||
log.info(added_servers)
|
||||
window('emby_servers', value=json.dumps(added_servers))
|
||||
window('emby_servers.json', value=added_servers)
|
||||
|
||||
def _reset_client(self):
|
||||
|
||||
|
|
|
@ -26,16 +26,21 @@ log = logging.getLogger("EMBY."+__name__)
|
|||
#################################################################################################
|
||||
# Main methods
|
||||
|
||||
def window(property, value=None, clear=False, window_id=10000):
|
||||
def window(property_, value=None, clear=False, window_id=10000):
|
||||
# Get or set window property
|
||||
WINDOW = xbmcgui.Window(window_id)
|
||||
|
||||
if clear:
|
||||
WINDOW.clearProperty(property)
|
||||
WINDOW.clearProperty(property_)
|
||||
elif value is not None:
|
||||
WINDOW.setProperty(property, value)
|
||||
if ".json" in property_:
|
||||
value = json.dumps(value)
|
||||
WINDOW.setProperty(property_, value)
|
||||
else:
|
||||
return WINDOW.getProperty(property)
|
||||
result = WINDOW.getProperty(property_)
|
||||
if result and ".json" in property_:
|
||||
result = json.loads(result)
|
||||
return result
|
||||
|
||||
def settings(setting, value=None):
|
||||
# Get or add addon setting
|
||||
|
|
Loading…
Reference in a new issue