Choose Plex user. Connection fixes
This commit is contained in:
parent
01f4833042
commit
dd1e873b20
2 changed files with 32 additions and 57 deletions
|
@ -152,14 +152,14 @@ class PlexAPI():
|
||||||
url = 'https://plex.tv/api/home/users'
|
url = 'https://plex.tv/api/home/users'
|
||||||
else:
|
else:
|
||||||
url = url + '/clients'
|
url = url + '/clients'
|
||||||
self.logMsg("CheckConnection called for url %s with a token" % url, 1)
|
self.logMsg("CheckConnection called for url %s with a token" % url, 2)
|
||||||
|
|
||||||
r = downloadutils.DownloadUtils().downloadUrl(
|
r = downloadutils.DownloadUtils().downloadUrl(
|
||||||
url,
|
url,
|
||||||
authenticate=False,
|
authenticate=False,
|
||||||
headerOptions={'X-Plex-Token': token}
|
headerOptions={'X-Plex-Token': token}
|
||||||
)
|
)
|
||||||
self.logMsg("Response was: %s" % r, 1)
|
self.logMsg("Response was: %s" % r, 2)
|
||||||
exceptionlist = [
|
exceptionlist = [
|
||||||
'',
|
'',
|
||||||
401
|
401
|
||||||
|
@ -859,8 +859,8 @@ class PlexAPI():
|
||||||
Output:
|
Output:
|
||||||
List of users, where one entry is of the form:
|
List of users, where one entry is of the form:
|
||||||
{
|
{
|
||||||
"User id": userId, "admin": True/False, "guest": True/False,
|
"User id": userId, "admin": '1'/'0', "guest": '1'/'0',
|
||||||
"restricted": True/False, "protected": True/False,
|
"restricted": '1'/'0', "protected": '1'/'0',
|
||||||
"email": email, "title": title, "username": username,
|
"email": email, "title": title, "username": username,
|
||||||
"thumb": thumb_url
|
"thumb": thumb_url
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,81 +180,56 @@ class InitialSetup():
|
||||||
self.addon.setSetting('https', 'false')
|
self.addon.setSetting('https', 'false')
|
||||||
|
|
||||||
##### USER INFO #####
|
##### USER INFO #####
|
||||||
|
|
||||||
self.logMsg("Getting user list.", 1)
|
self.logMsg("Getting user list.", 1)
|
||||||
# If not multiple users, set username to Plex login name.
|
# Get list of Plex home users
|
||||||
# If multiple users, get user list.
|
users = self.plx.MyPlexListHomeUsers(plexToken)
|
||||||
|
# Download users failed. Set username to Plex login
|
||||||
|
if not users:
|
||||||
url = "%s/emby/Users/Public?format=json" % server
|
utils.settings('username', value=plexLogin)
|
||||||
result = self.doUtils.downloadUrl(url, authenticate=False)
|
self.logMsg("User download failed. Set username = plexlogin", 1)
|
||||||
if result == "":
|
|
||||||
self.logMsg("Unable to connect to %s" % server, 1)
|
|
||||||
return
|
|
||||||
|
|
||||||
self.logMsg("Response: %s" % result, 2)
|
|
||||||
# Process the list of users
|
|
||||||
usernames = []
|
|
||||||
users_hasPassword = []
|
|
||||||
|
|
||||||
for user in result:
|
|
||||||
# Username
|
|
||||||
name = user['Name']
|
|
||||||
usernames.append(name)
|
|
||||||
# Password
|
|
||||||
if user['HasPassword']:
|
|
||||||
name = "%s (secure)" % name
|
|
||||||
users_hasPassword.append(name)
|
|
||||||
|
|
||||||
self.logMsg("Presenting user list: %s" % users_hasPassword, 1)
|
|
||||||
user_select = xbmcgui.Dialog().select(string(30200), users_hasPassword)
|
|
||||||
if user_select > -1:
|
|
||||||
selected_user = usernames[user_select]
|
|
||||||
self.logMsg("Selected user: %s" % selected_user, 1)
|
|
||||||
utils.settings('username', value=selected_user)
|
|
||||||
else:
|
else:
|
||||||
self.logMsg("No user selected.", 1)
|
userlist = []
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(%s)' % addonId)
|
for user in users:
|
||||||
|
username = user['title']
|
||||||
|
if user['admin'] == '1':
|
||||||
|
username = username + " (admin)"
|
||||||
|
userlist.append(username)
|
||||||
|
dialog = xbmcgui.Dialog()
|
||||||
|
user_select = dialog.select(string(30200), userlist)
|
||||||
|
if user_select > -1:
|
||||||
|
selected_user = userlist[user_select]
|
||||||
|
self.logMsg("Selected user: %s" % selected_user, 1)
|
||||||
|
utils.settings('username', value=selected_user)
|
||||||
|
else:
|
||||||
|
self.logMsg("No user selected.", 1)
|
||||||
|
xbmc.executebuiltin('Addon.OpenSettings(%s)' % addonId)
|
||||||
|
|
||||||
##### ADDITIONAL PROMPTS #####
|
##### ADDITIONAL PROMPTS #####
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
|
|
||||||
directPaths = dialog.yesno(
|
directPaths = dialog.yesno(
|
||||||
heading="Playback Mode",
|
heading="%s: Playback Mode" % self.addonName,
|
||||||
line1=(
|
line1=(
|
||||||
"Caution! If you choose Native mode, you "
|
"Caution! If you choose Native mode, you "
|
||||||
"will lose access to certain Emby features such as: "
|
"will probably lose access to certain Plex "
|
||||||
"Emby cinema mode, direct stream/transcode options, "
|
"features."),
|
||||||
"parental access schedule."),
|
|
||||||
nolabel="Addon (Default)",
|
nolabel="Addon (Default)",
|
||||||
yeslabel="Native (Direct Paths)")
|
yeslabel="Native (Direct Paths)")
|
||||||
if directPaths:
|
if directPaths:
|
||||||
self.logMsg("User opted to use direct paths.", 1)
|
self.logMsg("User opted to use direct paths.", 1)
|
||||||
utils.settings('useDirectPaths', value="1")
|
utils.settings('useDirectPaths', value="1")
|
||||||
|
|
||||||
# ask for credentials
|
|
||||||
credentials = dialog.yesno(
|
|
||||||
heading="Network credentials",
|
|
||||||
line1= (
|
|
||||||
"Add network credentials to allow Kodi access to your "
|
|
||||||
"content? Note: Skipping this step may generate a message "
|
|
||||||
"during the initial scan of your content if Kodi can't "
|
|
||||||
"locate your content."))
|
|
||||||
if credentials:
|
|
||||||
self.logMsg("Presenting network credentials dialog.", 1)
|
|
||||||
utils.passwordsXML()
|
|
||||||
|
|
||||||
musicDisabled = dialog.yesno(
|
musicDisabled = dialog.yesno(
|
||||||
heading="Music Library",
|
heading="%s: Music Library" % self.addonName,
|
||||||
line1="Disable Emby music library?")
|
line1="Disable Plex music library?")
|
||||||
if musicDisabled:
|
if musicDisabled:
|
||||||
self.logMsg("User opted to disable Emby music library.", 1)
|
self.logMsg("User opted to disable Plex music library.", 1)
|
||||||
utils.settings('enableMusic', value="false")
|
utils.settings('enableMusic', value="false")
|
||||||
else:
|
else:
|
||||||
# Only prompt if the user didn't select direct paths for videos
|
# Only prompt if the user didn't select direct paths for videos
|
||||||
if not directPaths:
|
if not directPaths:
|
||||||
musicAccess = dialog.yesno(
|
musicAccess = dialog.yesno(
|
||||||
heading="Music Library",
|
heading="%s: Music Library" % self.addonName,
|
||||||
line1=(
|
line1=(
|
||||||
"Direct stream the music library? Select "
|
"Direct stream the music library? Select "
|
||||||
"this option only if you plan on listening "
|
"this option only if you plan on listening "
|
||||||
|
|
Loading…
Add table
Reference in a new issue