New Setting: Choose Plex Server from a list
This commit is contained in:
parent
eca710f2a9
commit
8abd987d2b
7 changed files with 93 additions and 22 deletions
|
@ -70,7 +70,8 @@ class Main:
|
||||||
'reConnect': entrypoint.reConnect,
|
'reConnect': entrypoint.reConnect,
|
||||||
'delete': entrypoint.deleteItem,
|
'delete': entrypoint.deleteItem,
|
||||||
'browseplex': entrypoint.BrowsePlexContent,
|
'browseplex': entrypoint.BrowsePlexContent,
|
||||||
'ondeck': entrypoint.getOnDeck
|
'ondeck': entrypoint.getOnDeck,
|
||||||
|
'chooseServer': entrypoint.chooseServer
|
||||||
}
|
}
|
||||||
|
|
||||||
if "/extrafanart" in sys.argv[0]:
|
if "/extrafanart" in sys.argv[0]:
|
||||||
|
|
|
@ -392,6 +392,7 @@
|
||||||
<string id="39047">On Deck: Append show title to episode</string>
|
<string id="39047">On Deck: Append show title to episode</string>
|
||||||
<string id="39048">On Deck: Append season- and episode-number (e.g. S3E2)</string>
|
<string id="39048">On Deck: Append season- and episode-number (e.g. S3E2)</string>
|
||||||
<string id="39049">Nothing works? Try a full reset!</string>
|
<string id="39049">Nothing works? Try a full reset!</string>
|
||||||
|
<string id="39050">[COLOR yellow]Choose Plex Server from a list[/COLOR]</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Plex Entrypoint.py -->
|
<!-- Plex Entrypoint.py -->
|
||||||
|
|
|
@ -330,6 +330,7 @@
|
||||||
<string id="39047">"Aktuell": Serien- an Episoden-Titel anfügen</string>
|
<string id="39047">"Aktuell": Serien- an Episoden-Titel anfügen</string>
|
||||||
<string id="39048">"Aktuell": Staffel und Episode anfügen (z.B. S3E2)</string>
|
<string id="39048">"Aktuell": Staffel und Episode anfügen (z.B. S3E2)</string>
|
||||||
<string id="39049">Nichts funktioniert? Setze mal alles zurück!</string>
|
<string id="39049">Nichts funktioniert? Setze mal alles zurück!</string>
|
||||||
|
<string id="39050">[COLOR yellow]Plex Server aus Liste auswählen[/COLOR]</string>
|
||||||
|
|
||||||
<!-- Plex Entrypoint.py -->
|
<!-- Plex Entrypoint.py -->
|
||||||
<string id="39200">Plex Home Benutzer abmelden: </string>
|
<string id="39200">Plex Home Benutzer abmelden: </string>
|
||||||
|
|
|
@ -2168,14 +2168,14 @@ class API():
|
||||||
transcodePath = self.server + \
|
transcodePath = self.server + \
|
||||||
'/video/:/transcode/universal/start.m3u8?'
|
'/video/:/transcode/universal/start.m3u8?'
|
||||||
args = {
|
args = {
|
||||||
'copyts': 1,
|
'protocol': 'hls', # seen in the wild: 'dash', 'http', 'hls'
|
||||||
|
'session': str(uuid4()),
|
||||||
|
'fastSeek': 1,
|
||||||
'path': path,
|
'path': path,
|
||||||
'mediaIndex': 0, # Probably refering to XML reply sheme
|
'mediaIndex': 0, # Probably refering to XML reply sheme
|
||||||
'partIndex': self.part,
|
'partIndex': self.part,
|
||||||
'protocol': 'hls', # seen in the wild: 'dash', 'http', 'hls'
|
# 'copyts': 1,
|
||||||
'session': str(uuid4()),
|
|
||||||
# 'offset': 0, # Resume point
|
# 'offset': 0, # Resume point
|
||||||
'fastSeek': 1
|
|
||||||
}
|
}
|
||||||
# Seem like PHT to let the PMS use the transcoding profile
|
# Seem like PHT to let the PMS use the transcoding profile
|
||||||
xargs['X-Plex-Device'] = 'Plex Home Theater'
|
xargs['X-Plex-Device'] = 'Plex Home Theater'
|
||||||
|
|
|
@ -73,36 +73,100 @@ def plexCompanion(fullurl, params):
|
||||||
title, "Not knowing what to do for now - no playQueue sent", -1)
|
title, "Not knowing what to do for now - no playQueue sent", -1)
|
||||||
|
|
||||||
|
|
||||||
def reConnect():
|
def chooseServer():
|
||||||
"""
|
"""
|
||||||
Triggers login to plex.tv and re-authorization
|
Lets user choose from list of PMS (signs out & signs in)
|
||||||
"""
|
"""
|
||||||
string = xbmcaddon.Addon().getLocalizedString
|
string = xbmcaddon.Addon().getLocalizedString
|
||||||
utils.logMsg("entrypoint reConnect",
|
utils.logMsg(title, "Choosing PMS server requested, starting", 0)
|
||||||
"Connection resets requested", 0)
|
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
# Resetting, please wait
|
# Resetting, please wait
|
||||||
dialog.notification(
|
dialog.notification(
|
||||||
heading=addonName,
|
heading=addonName,
|
||||||
message=string(39207),
|
message=string(39207),
|
||||||
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||||
time=2000,
|
time=3000,
|
||||||
sound=False)
|
sound=False)
|
||||||
# Pause library sync thread - user needs to be auth in order to sync
|
# Pause library sync thread - user needs to be auth in order to sync
|
||||||
utils.window('suspend_LibraryThread', value='true')
|
utils.window('suspend_LibraryThread', value='true')
|
||||||
# Wait max for 5 seconds for all lib scans to finish
|
# Wait max for 25 seconds for all lib scans to finish
|
||||||
counter = 0
|
counter = 0
|
||||||
while utils.window('emby_dbScan') == 'true':
|
while utils.window('emby_dbScan') == 'true':
|
||||||
if counter > 500:
|
if counter > 500:
|
||||||
# Failed to reset PMS and plex.tv connects. Try to restart Kodi.
|
# Failed to reset PMS and plex.tv connects. Try to restart Kodi.
|
||||||
dialog.ok(heading=addonName,
|
dialog.ok(addonName,
|
||||||
message=string(39208))
|
string(39208))
|
||||||
# Resuming threads, just in case
|
# Resuming threads, just in case
|
||||||
utils.window('suspend_LibraryThread', clear=True)
|
utils.window('suspend_LibraryThread', clear=True)
|
||||||
# Abort reConnection
|
utils.logMsg(title, "Could not stop library sync, aborting", -1)
|
||||||
return
|
return
|
||||||
counter += 1
|
counter += 1
|
||||||
xbmc.sleep(50)
|
xbmc.sleep(50)
|
||||||
|
utils.logMsg(title, "Successfully stopped library sync", 0)
|
||||||
|
|
||||||
|
# Reset connection details
|
||||||
|
utils.settings('plex_machineIdentifier', value="")
|
||||||
|
utils.settings('plex_servername', value="")
|
||||||
|
utils.settings('https', value="")
|
||||||
|
utils.settings('ipaddress', value="")
|
||||||
|
utils.settings('port', value="")
|
||||||
|
|
||||||
|
# Log out currently signed in user:
|
||||||
|
utils.window('emby_serverStatus', value="401")
|
||||||
|
|
||||||
|
# Above method needs to have run its course! Hence wait
|
||||||
|
counter = 0
|
||||||
|
while utils.window('emby_serverStatus') == "401":
|
||||||
|
if counter > 100:
|
||||||
|
dialog.ok(addonName,
|
||||||
|
string(39208))
|
||||||
|
utils.logMsg(title, "Could not sign out, aborting", -1)
|
||||||
|
return
|
||||||
|
counter += 1
|
||||||
|
xbmc.sleep(50)
|
||||||
|
# Suspend the user client during procedure
|
||||||
|
utils.window('suspend_Userclient', value='true')
|
||||||
|
|
||||||
|
import initialsetup
|
||||||
|
initialsetup.InitialSetup().setup(chooseServer=True)
|
||||||
|
# Request lib sync to get user view data (e.g. watched/unwatched)
|
||||||
|
utils.window('plex_runLibScan', value='full')
|
||||||
|
# Restart user client
|
||||||
|
utils.window('suspend_Userclient', clear=True)
|
||||||
|
utils.logMsg(title, "Choosing new PMS complete", 0)
|
||||||
|
|
||||||
|
|
||||||
|
def reConnect():
|
||||||
|
"""
|
||||||
|
Triggers login to plex.tv and re-authorization
|
||||||
|
"""
|
||||||
|
string = xbmcaddon.Addon().getLocalizedString
|
||||||
|
utils.logMsg(title, "Connection resets requested", 0)
|
||||||
|
dialog = xbmcgui.Dialog()
|
||||||
|
# Resetting, please wait
|
||||||
|
dialog.notification(
|
||||||
|
heading=addonName,
|
||||||
|
message=string(39207),
|
||||||
|
icon="special://home/addons/plugin.video.plexkodiconnect/icon.png",
|
||||||
|
time=3000,
|
||||||
|
sound=False)
|
||||||
|
# Pause library sync thread - user needs to be auth in order to sync
|
||||||
|
utils.window('suspend_LibraryThread', value='true')
|
||||||
|
# Wait max for 25 seconds for all lib scans to finish
|
||||||
|
counter = 0
|
||||||
|
while utils.window('emby_dbScan') == 'true':
|
||||||
|
if counter > 500:
|
||||||
|
# Failed to reset PMS and plex.tv connects. Try to restart Kodi.
|
||||||
|
dialog.ok(addonName,
|
||||||
|
string(39208))
|
||||||
|
# Resuming threads, just in case
|
||||||
|
utils.window('suspend_LibraryThread', clear=True)
|
||||||
|
utils.logMsg(title, "Could not stop library sync, aborting", -1)
|
||||||
|
return
|
||||||
|
counter += 1
|
||||||
|
xbmc.sleep(50)
|
||||||
|
|
||||||
|
utils.logMsg(title, "Successfully stopped library sync", 0)
|
||||||
|
|
||||||
# Delete plex credentials in settings
|
# Delete plex credentials in settings
|
||||||
utils.settings('myplexlogin', value="true")
|
utils.settings('myplexlogin', value="true")
|
||||||
|
@ -126,9 +190,9 @@ def reConnect():
|
||||||
counter = 0
|
counter = 0
|
||||||
while utils.window('emby_serverStatus') == "401":
|
while utils.window('emby_serverStatus') == "401":
|
||||||
if counter > 100:
|
if counter > 100:
|
||||||
dialog.ok(heading=addonName,
|
dialog.ok(addonName,
|
||||||
message=string(39208))
|
string(39208))
|
||||||
# Abort reConnection
|
utils.logMsg(title, "Could not sign out, aborting", -1)
|
||||||
return
|
return
|
||||||
counter += 1
|
counter += 1
|
||||||
xbmc.sleep(50)
|
xbmc.sleep(50)
|
||||||
|
@ -141,6 +205,7 @@ def reConnect():
|
||||||
utils.window('plex_runLibScan', value='full')
|
utils.window('plex_runLibScan', value='full')
|
||||||
# Restart user client
|
# Restart user client
|
||||||
utils.window('suspend_Userclient', clear=True)
|
utils.window('suspend_Userclient', clear=True)
|
||||||
|
utils.logMsg(title, "Complete reconnection to plex.tv and PMS complete", 0)
|
||||||
|
|
||||||
|
|
||||||
def PassPlaylist(xml, resume=None):
|
def PassPlaylist(xml, resume=None):
|
||||||
|
|
|
@ -26,7 +26,7 @@ class InitialSetup():
|
||||||
self.userClient = userclient.UserClient()
|
self.userClient = userclient.UserClient()
|
||||||
self.plx = PlexAPI.PlexAPI()
|
self.plx = PlexAPI.PlexAPI()
|
||||||
|
|
||||||
def setup(self, forcePlexTV=False):
|
def setup(self, forcePlexTV=False, chooseServer=False):
|
||||||
"""
|
"""
|
||||||
Initial setup. Run once upon startup.
|
Initial setup. Run once upon startup.
|
||||||
Check server, user, direct paths, music, direct stream if not direct
|
Check server, user, direct paths, music, direct stream if not direct
|
||||||
|
@ -51,7 +51,8 @@ class InitialSetup():
|
||||||
|
|
||||||
# Optionally sign into plex.tv. Will not be called on very first run
|
# Optionally sign into plex.tv. Will not be called on very first run
|
||||||
# as plexToken will be ''
|
# as plexToken will be ''
|
||||||
if (plexToken and myplexlogin == 'true' and forcePlexTV is False):
|
if (plexToken and myplexlogin == 'true' and forcePlexTV is False
|
||||||
|
and chooseServer is False):
|
||||||
chk = self.plx.CheckConnection('plex.tv', plexToken)
|
chk = self.plx.CheckConnection('plex.tv', plexToken)
|
||||||
# HTTP Error: unauthorized. Token is no longer valid
|
# HTTP Error: unauthorized. Token is no longer valid
|
||||||
if chk == 401 or chk == 403:
|
if chk == 401 or chk == 403:
|
||||||
|
@ -92,7 +93,7 @@ class InitialSetup():
|
||||||
self.logMsg('Failed to update Plex info from plex.tv', -1)
|
self.logMsg('Failed to update Plex info from plex.tv', -1)
|
||||||
|
|
||||||
# If a Plex server IP has already been set, return.
|
# If a Plex server IP has already been set, return.
|
||||||
if server and forcePlexTV is False:
|
if server and forcePlexTV is False and chooseServer is False:
|
||||||
self.logMsg("Server is already set.", 0)
|
self.logMsg("Server is already set.", 0)
|
||||||
self.logMsg("url: %s, Plex machineIdentifier: %s"
|
self.logMsg("url: %s, Plex machineIdentifier: %s"
|
||||||
% (server, serverid), 0)
|
% (server, serverid), 0)
|
||||||
|
@ -100,7 +101,8 @@ class InitialSetup():
|
||||||
|
|
||||||
# If not already retrieved myplex info, optionally let user sign in
|
# If not already retrieved myplex info, optionally let user sign in
|
||||||
# to plex.tv. This DOES get called on very first install run
|
# to plex.tv. This DOES get called on very first install run
|
||||||
if ((not plexToken and myplexlogin == 'true') or forcePlexTV):
|
if ((not plexToken and myplexlogin == 'true' and chooseServer is False)
|
||||||
|
or forcePlexTV):
|
||||||
result = self.plx.PlexTvSignInWithPin()
|
result = self.plx.PlexTvSignInWithPin()
|
||||||
if result:
|
if result:
|
||||||
plexLogin = result['username']
|
plexLogin = result['username']
|
||||||
|
@ -231,7 +233,7 @@ class InitialSetup():
|
||||||
# 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")
|
||||||
|
|
||||||
if forcePlexTV:
|
if forcePlexTV is True or chooseServer is True:
|
||||||
return
|
return
|
||||||
|
|
||||||
goToSettings = False
|
goToSettings = False
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<settings>
|
<settings>
|
||||||
<category label="30014"><!-- Connection -->
|
<category label="30014"><!-- Connection -->
|
||||||
<!-- Primary address -->
|
<!-- Primary address -->
|
||||||
|
<setting label="39050" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect?mode=chooseServer)" option="close" /><!-- Choose Plex Server from a list -->
|
||||||
<setting id="ipaddress" label="30000" type="text" default="" />
|
<setting id="ipaddress" label="30000" type="text" default="" />
|
||||||
<setting id="port" label="30030" type="number" default="32400" />
|
<setting id="port" label="30030" type="number" default="32400" />
|
||||||
<setting id="https" label="30243" type="bool" default="false" />
|
<setting id="https" label="30243" type="bool" default="false" />
|
||||||
|
|
Loading…
Reference in a new issue