mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Add/Remove additional user from session
Can be mapped to home menu or keymap using: RunPlugin(plugin://plugin.video.emby?mode=adduser)
This commit is contained in:
parent
d8fd3603a6
commit
0501622b59
3 changed files with 86 additions and 0 deletions
|
@ -37,6 +37,9 @@ elif mode == "reset":
|
|||
elif mode == "resetauth":
|
||||
entrypoint.resetAuth()
|
||||
|
||||
elif mode == "adduser":
|
||||
entrypoint.addUser()
|
||||
|
||||
##### BROWSE EMBY CHANNELS ROOT #####
|
||||
elif mode == "channels":
|
||||
entrypoint.BrowseChannels(id)
|
||||
|
|
|
@ -12,6 +12,7 @@ import urllib
|
|||
WINDOW = xbmcgui.Window(10000)
|
||||
|
||||
import Utils as utils
|
||||
from ClientInformation import ClientInformation
|
||||
from PlaybackUtils import PlaybackUtils
|
||||
from DownloadUtils import DownloadUtils
|
||||
from ReadEmbyDB import ReadEmbyDB
|
||||
|
@ -35,6 +36,87 @@ def resetAuth():
|
|||
else:
|
||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
|
||||
|
||||
### ADD ADDITIONAL USERS ###
|
||||
def addUser():
|
||||
|
||||
doUtils = DownloadUtils()
|
||||
clientInfo = ClientInformation()
|
||||
currUser = WINDOW.getProperty("currUser")
|
||||
deviceId = clientInfo.getMachineId()
|
||||
deviceName = clientInfo.getDeviceName()
|
||||
|
||||
# Get session
|
||||
url = "{server}/mediabrowser/Sessions?DeviceId=%s" % deviceId
|
||||
result = doUtils.downloadUrl(url)
|
||||
|
||||
try:
|
||||
sessionId = result[0][u'Id']
|
||||
additionalUsers = result[0][u'AdditionalUsers']
|
||||
# Add user to session
|
||||
userlist = {}
|
||||
users = []
|
||||
url = "{server}/mediabrowser/Users?IsDisabled=false"
|
||||
result = doUtils.downloadUrl(url)
|
||||
|
||||
# pull the list of users
|
||||
for user in result:
|
||||
name = user[u'Name']
|
||||
userId = user[u'Id']
|
||||
if currUser not in name:
|
||||
userlist[name] = userId
|
||||
users.append(name)
|
||||
|
||||
# Display dialog if there's additional users
|
||||
if additionalUsers:
|
||||
|
||||
option = xbmcgui.Dialog().select("Add/Remove user from the session", ["Add user", "Remove user"])
|
||||
# Users currently in the session
|
||||
additionalUserlist = {}
|
||||
additionalUsername = []
|
||||
# Users currently in the session
|
||||
for user in additionalUsers:
|
||||
name = user[u'UserName']
|
||||
userId = user[u'UserId']
|
||||
additionalUserlist[name] = userId
|
||||
additionalUsername.append(name)
|
||||
|
||||
if option == 1:
|
||||
# User selected Remove user
|
||||
resp = xbmcgui.Dialog().select("Remove user from the session", additionalUsername)
|
||||
if resp > -1:
|
||||
selected = additionalUsername[resp]
|
||||
selected_userId = additionalUserlist[selected]
|
||||
url = "{server}/mediabrowser/Sessions/%s/Users/%s" % (sessionId, selected_userId)
|
||||
postdata = {}
|
||||
doUtils.downloadUrl(url, postBody=postdata, type="DELETE")
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
||||
elif option == 0:
|
||||
# User selected Add user
|
||||
for adduser in additionalUsername:
|
||||
xbmc.log(str(adduser))
|
||||
users.remove(adduser)
|
||||
|
||||
elif option < 0:
|
||||
# User cancelled
|
||||
return
|
||||
|
||||
# Subtract any additional users
|
||||
xbmc.log("Displaying list of users: %s" % users)
|
||||
resp = xbmcgui.Dialog().select("Add user to the session", users)
|
||||
# post additional user
|
||||
if resp > -1:
|
||||
selected = users[resp]
|
||||
selected_userId = userlist[selected]
|
||||
url = "{server}/mediabrowser/Sessions/%s/Users/%s" % (sessionId, selected_userId)
|
||||
postdata = {}
|
||||
doUtils.downloadUrl(url, postBody=postdata, type="POST")
|
||||
|
||||
except:
|
||||
xbmc.log("Failed to add user to session.")
|
||||
|
||||
##### BROWSE EMBY CHANNELS #####
|
||||
def BrowseChannels(id, folderid=None):
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<setting type="sep" />
|
||||
<setting id="accessToken" type="text" visible="false" default="" />
|
||||
<setting label="[COLOR yellow]Reset login attempts[/COLOR]" type="action" visible="eq(-1,) + !eq(-9,)" enable="true" action="RunPlugin(plugin://plugin.video.emby?mode=resetauth)" option="close" />
|
||||
<setting label="Add/Remove additional user to the session" type="action" visible="true" action="RunPlugin(plugin://plugin.video.emby?mode=adduser)" option="close" />
|
||||
</category>
|
||||
<category label="Sync Options">
|
||||
<!-- <setting id="syncMovieBoxSets" type="bool" label="30238" default="true" visible="true" enable="true" /> -->
|
||||
|
|
Loading…
Reference in a new issue