mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-13 21:56:11 +00:00
1c450cb257
Artwork wasn't displaying for Isengard
104 lines
2.8 KiB
Python
104 lines
2.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
##################################################################################################
|
|
|
|
import logging
|
|
|
|
import xbmc
|
|
import xbmcgui
|
|
|
|
##################################################################################################
|
|
|
|
log = logging.getLogger("EMBY."+__name__)
|
|
|
|
ACTION_PARENT_DIR = 9
|
|
ACTION_PREVIOUS_MENU = 10
|
|
ACTION_BACK = 92
|
|
ACTION_SELECT_ITEM = 7
|
|
ACTION_MOUSE_LEFT_CLICK = 100
|
|
LIST = 155
|
|
MANUAL = 200
|
|
CANCEL = 201
|
|
|
|
##################################################################################################
|
|
|
|
|
|
class UsersConnect(xbmcgui.WindowXMLDialog):
|
|
|
|
_user = None
|
|
_manual_login = False
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
self.kodi_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
|
|
xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
|
|
|
|
def set_server(self, server):
|
|
self.server = server
|
|
|
|
def set_users(self, users):
|
|
self.users = users
|
|
|
|
def is_user_selected(self):
|
|
return True if self._user else False
|
|
|
|
def get_user(self):
|
|
return self._user
|
|
|
|
def is_manual_login(self):
|
|
return self._manual_login
|
|
|
|
|
|
def onInit(self):
|
|
|
|
self.list_ = self.getControl(LIST)
|
|
for user in self.users:
|
|
user_image = ("userflyoutdefault2.png" if 'PrimaryImageTag' not in user
|
|
else self._get_user_artwork(user['Id'], 'Primary'))
|
|
self.list_.addItem(self._add_listitem(user['Name'], user['Id'], user_image))
|
|
|
|
self.setFocus(self.list_)
|
|
|
|
def _add_listitem(self, label, user_id, user_image):
|
|
|
|
item = xbmcgui.ListItem(label)
|
|
item.setProperty('id', user_id)
|
|
if self.kodi_version > 15:
|
|
item.setArt({'Icon': user_image})
|
|
else:
|
|
item.setIconImage(user_image)
|
|
|
|
return item
|
|
|
|
def onAction(self, action):
|
|
|
|
if action in (ACTION_BACK, ACTION_PREVIOUS_MENU, ACTION_PARENT_DIR):
|
|
self.close()
|
|
|
|
if action in (ACTION_SELECT_ITEM, ACTION_MOUSE_LEFT_CLICK):
|
|
|
|
if self.getFocusId() == LIST:
|
|
user = self.list_.getSelectedItem()
|
|
selected_id = user.getProperty('id')
|
|
log.info('User Id selected: %s', selected_id)
|
|
|
|
for user in self.users:
|
|
if user['Id'] == selected_id:
|
|
self._user = user
|
|
break
|
|
|
|
self.close()
|
|
|
|
def onClick(self, control):
|
|
|
|
if control == MANUAL:
|
|
self._manual_login = True
|
|
self.close()
|
|
|
|
elif control == CANCEL:
|
|
self.close()
|
|
|
|
def _get_user_artwork(self, user_id, item_type):
|
|
# Load user information set by UserClient
|
|
return "%s/emby/Users/%s/Images/%s?Format=original" % (self.server, user_id, item_type)
|