本文整理匯總了Python中DPH_Singleton.Singleton.getPlexUserTokenForLocalServerAuthentication方法的典型用法代碼示例。如果您正苦於以下問題:Python Singleton.getPlexUserTokenForLocalServerAuthentication方法的具體用法?Python Singleton.getPlexUserTokenForLocalServerAuthentication怎麽用?Python Singleton.getPlexUserTokenForLocalServerAuthentication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DPH_Singleton.Singleton
的用法示例。
在下文中一共展示了Singleton.getPlexUserTokenForLocalServerAuthentication方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DPS_ServerMenu
# 需要導入模塊: from DPH_Singleton import Singleton [as 別名]
# 或者: from DPH_Singleton.Singleton import getPlexUserTokenForLocalServerAuthentication [as 別名]
#.........這裏部分代碼省略.........
self.session.openWithCallback(
self.askForPin, InputBox, title=_("Please enter the pincode!"), type=Input.PIN
)
else:
self.switchUser()
else:
if self.g_serverConfig.myplexPinProtect.value:
self.session.openWithCallback(
self.askForPin, InputBox, title=_("Please enter the pincode!"), type=Input.PIN
)
self.currentPin = self.g_serverConfig.myplexPin.value
else:
self.switchUser()
printl("", self, "C")
# ===============================================================
#
# ===============================================================
def switchUser(self):
printl("", self, "S")
# TODO add use saved values if we have no internet connection
xmlResponse = self.plexInstance.switchHomeUser(self.currentHomeUserId, self.currentHomeUserPin)
entryData = dict(xmlResponse.items())
myId = entryData["id"]
token = entryData["authenticationToken"]
title = entryData["title"]
self.plexInstance.serverConfig_myplexToken = token
accessToken = self.plexInstance.getPlexUserTokenForLocalServerAuthentication(self.plexInstance.g_host)
if not accessToken:
# we get all the restriction data from plex and not from the local server this means that if we ar not connected no data is coming to check, means no restction
self.session.open(
MessageBox, "No accessToken! Check plex.tv connection and plexPass status.", MessageBox.TYPE_INFO
)
else:
self.g_serverConfig.myplexCurrentHomeUser.value = title
self.g_serverConfig.myplexCurrentHomeUserAccessToken.value = accessToken
self.g_serverConfig.myplexCurrentHomeUserId.value = myId
self.g_serverConfig.save()
self.plexInstance.setAccessTokenHeader(self.plexInstance.g_currentServer, accessToken)
self["text_HomeUser"].setText(title)
printl("", self, "C")
# ===============================================================
#
# ===============================================================
def askForPin(self, enteredPin):
printl("", self, "S")
if enteredPin is None:
pass
else:
if int(enteredPin) == int(self.currentPin):
self.session.open(MessageBox, "The pin was correct! Switching user.", MessageBox.TYPE_INFO)
if self.isHomeUser:
self.switchUser()
示例2: DPS_ServerConfig
# 需要導入模塊: from DPH_Singleton import Singleton [as 別名]
# 或者: from DPH_Singleton.Singleton import getPlexUserTokenForLocalServerAuthentication [as 別名]
#.........這裏部分代碼省略.........
self.close()
printl("", self, "C")
# ===========================================================================
#
# ===========================================================================
def keyCancel(self):
printl("", self, "S")
if self.newmode == 1:
config.plugins.dreamplex.Entries.remove(self.current)
ConfigListScreen.cancelConfirm(self, True)
printl("", self, "C")
# ===========================================================================
#
# ===========================================================================
def keyYellow(self):
printl("", self, "S")
if self.useMappings:
serverID = self.currentId
self.session.open(DPS_Mappings, serverID)
elif self.current.localAuth.value:
# now that we know the server we establish global plexInstance
self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
ipInConfig = "%d.%d.%d.%d" % tuple(self.current.ip.value)
token = self.plexInstance.getPlexUserTokenForLocalServerAuthentication(ipInConfig)
if token:
self.current.myplexLocalToken.value = token
self.current.myplexLocalToken.save()
self.session.open(
MessageBox,
(_("Local Token:") + "\n%s \n" + _("for the user:") + "\n%s")
% (token, self.current.myplexTokenUsername.value),
MessageBox.TYPE_INFO,
)
else:
response = self.plexInstance.getLastResponse()
self.session.open(
MessageBox,
(_("Error:") + "\n%s \n" + _("for the user:") + "\n%s")
% (response, self.current.myplexTokenUsername.value),
MessageBox.TYPE_INFO,
)
printl("", self, "C")
# ===========================================================================
#
# ===========================================================================
def keyBlue(self):
printl("", self, "S")
# now that we know the server we establish global plexInstance
self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
token = self.plexInstance.getNewMyPlexToken()
示例3: DPS_ServerConfig
# 需要導入模塊: from DPH_Singleton import Singleton [as 別名]
# 或者: from DPH_Singleton.Singleton import getPlexUserTokenForLocalServerAuthentication [as 別名]
#.........這裏部分代碼省略.........
if machineIdentifier is not None:
machineIdentifiers += xmlResponse.get("machineIdentifier")
self.current.machineIdentifier.value = machineIdentifiers
printl("machineIdentifier: " + str(self.current.machineIdentifier.value), self, "D")
if self.current.connectionType.value == "2" or self.current.localAuth.value:
self.keyBlue()
else:
self.saveNow()
printl("", self, "C")
#===========================================================================
#
#===========================================================================
def saveNow(self, retval=None):
printl("", self, "S")
config.plugins.dreamplex.entriescount.save()
config.plugins.dreamplex.Entries.save()
config.plugins.dreamplex.save()
configfile.save()
self.close()
printl("", self, "C")
#===========================================================================
#
#===========================================================================
def keyCancel(self):
printl("", self, "S")
if self.newmode == 1:
config.plugins.dreamplex.Entries.remove(self.current)
ConfigListScreen.cancelConfirm(self, True)
printl("", self, "C")
#===========================================================================
#
#===========================================================================
def keyYellow(self):
printl("", self, "S")
if self.useMappings:
serverID = self.currentId
self.session.open(DPS_Mappings, serverID)
elif self.current.localAuth.value:
# now that we know the server we establish global plexInstance
self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
ipInConfig = "%d.%d.%d.%d" % tuple(self.current.ip.value)
token = self.plexInstance.getPlexUserTokenForLocalServerAuthentication(ipInConfig)
if token:
self.current.myplexLocalToken.value = token
self.current.myplexLocalToken.save()
self.session.open(MessageBox,(_("Local Token:") + "\n%s \n" + _("for the user:") + "\n%s") % (token, self.current.myplexTokenUsername.value), MessageBox.TYPE_INFO)
else:
response = self.plexInstance.getLastResponse()
self.session.open(MessageBox,(_("Error:") + "\n%s \n" + _("for the user:") + "\n%s") % (response, self.current.myplexTokenUsername.value), MessageBox.TYPE_INFO)
printl("", self, "C")
#===========================================================================
#
#===========================================================================
def keyBlue(self):
printl("", self, "S")
# now that we know the server we establish global plexInstance
self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
token = self.plexInstance.getNewMyPlexToken()
if token:
self.session.openWithCallback(self.saveNow, MessageBox,(_("myPlex Token:") + "\n%s \n" + _("for the user:") + "\n%s \n" + _("with the id:") + "\n%s") % (token, self.current.myplexTokenUsername.value, self.current.myplexId.value), MessageBox.TYPE_INFO)
else:
response = self.plexInstance.getLastResponse()
self.session.openWithCallback(self.saveNow, MessageBox,(_("Error:") + "\n%s \n" + _("for the user:") + "\n%s") % (response, self.current.myplexTokenUsername.value), MessageBox.TYPE_INFO)
printl("", self, "C")
#===========================================================================
#
#===========================================================================
def keyRed(self):
printl("", self, "S")
if self.useHomeUsers:
serverID = self.currentId
plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
self.session.open(DPS_Users, serverID, plexInstance)
#self.session.open(MessageBox,(_("myPlex Token:") + "\n%s \n" + _("myPlex Localtoken:") + "\n%s \n"+ _("for the user:") + "\n%s") % (self.current.myplexToken.value, self.current.myplexLocalToken.value, self.current.myplexTokenUsername.value), MessageBox.TYPE_INFO)
printl("", self, "C")