From 8e9b355473a23c8781cd6d0af033226a8e0913ce Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Tue, 8 Mar 2016 09:20:06 +0100 Subject: [PATCH] New Setting to reset all PMS and the plex.tv connection --- default.py | 2 +- resources/language/English/strings.xml | 4 ++- resources/language/German/strings.xml | 6 +++- resources/lib/entrypoint.py | 38 +++++++++++++++++++++++--- resources/settings.xml | 2 +- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/default.py b/default.py index 0cc69761..6864431c 100644 --- a/default.py +++ b/default.py @@ -66,7 +66,7 @@ class Main: 'companion': entrypoint.plexCompanion, 'switchuser': entrypoint.switchPlexUser, 'deviceid': entrypoint.resetDeviceId, - 'doPlexTvLogin': entrypoint.doPlexTvLogin + 'reConnect': entrypoint.reConnect } if "/extrafanart" in sys.argv[0]: diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 51e5c48c..8fa4b09c 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -362,7 +362,7 @@ [COLOR yellow]Sync Emby Theme Media to Kodi[/COLOR] (local) Failed to authenticate. Did you login to plex.tv? - [COLOR yellow]Log into plex.tv[/COLOR] + [COLOR yellow]Reset PMS and plex.tv connections to re-login[/COLOR] Automatically log into plex.tv on startup Enable constant background sync (restart Kodi!) @@ -375,6 +375,8 @@ Perform manual library sync Unable to run the sync, the add-on is not connected to a Plex server. Plex might lock your account if you fail to log in too many times. Proceed anyway? + Reseting PMS connections, please wait. Test: עޥ + Failed to reset PMS and plex.tv connects. Try to restart Kodi. diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index d42cb99a..a1f6eb53 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -293,7 +293,7 @@ [COLOR yellow]Plex Themes zu Kodi synchronisieren[/COLOR] (lokal) Plex Media Server Authentifizierung fehlgeschlagen. Haben Sie sich bei plex.tv eingeloggt? - [COLOR yellow]Bei plex.tv einloggen[/COLOR] + [COLOR yellow]PMS und plex.tv Verbindungen zurücksetzen für erneuten Login[/COLOR] Automatisch beim Starten bei plex.tv einloggen Laufende Synchronisierung im Hintergrund aktivieren (Neustart!) @@ -305,6 +305,10 @@ Manuellen Scan der Plex Bibliotheken starten Plex Bibliothek kann nicht gescannt werden, da keine Verbindung mit einem Plex Server besteht. Plex könnte möglicherweise Ihren Account sperren, wenn Sie zu oft versuchen, sich erfolglos anzumelden. Trotzdem fortfahren? + PMS Verbindungen werden zurückgesetzt + PMS und plex.tv Verbindungen konnten nicht zurückgesetzt werden. Bitte versuchen Sie, Kodi neu zu starten, um das Problem zu beheben. + + Alle Plex Bilder in Kodi zwischenzuspeichern kann sehr lange dauern. Möchten Sie wirklich fortfahren? diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 5080bccd..8f0c6703 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -72,18 +72,48 @@ def plexCompanion(fullurl, params): title, "Not knowing what to do for now - no playQueue sent", -1) -def doPlexTvLogin(): +def reConnect(): """ - Triggers login to plex.tv + Triggers login to plex.tv and re-authorization """ + string = xbmcaddon.Addon().getLocalizedString + utils.logMsg("entrypoint reConnect", + "Connection resets requested", 0) + # Pause library sync thread - user needs to be auth in order to sync + utils.window('suspend_LibraryThread', value='true') # Suspend the user client during procedure utils.window('suspend_Userclient', value='true') + dialog = xbmcgui.Dialog() + dialog.notification( + heading=addonName, + message=string(39207), + icon="special://home/addons/plugin.video.plexkodiconnect/icon.png", + sound=False) + + # Wait max for 20 seconds for all lib scans to finish + counter = 0 + while utils.window('emby_dbScan') == 'true': + xbmc.sleep(1000) + counter += 1 + if counter > 20: + dialog.ok( + heading=addonName, + message=string(39208).encode('utf-8'), + ) + # Resuming threads, just in case + utils.window('suspend_LibraryThread', clear=True) + utils.window('suspend_Userclient', clear=True) + # Abort reConnection + return + import initialsetup initialsetup.InitialSetup().setup(forcePlexTV=True) - utils.logMsg("PLEX", "Reset login attempts.", 1) - utils.window('emby_serverStatus', value="Auth") + # Log out currently signed in user: + utils.window('emby_serverStatus', value="401") # Restart user client utils.window('suspend_Userclient', clear=True) + # Request lib sync to get user view data (e.g. watched/unwatched) + utils.window('plex_runLibScan', value='full') def PassPlaylist(xml, resume=None): diff --git a/resources/settings.xml b/resources/settings.xml index 517ec5f9..0de69e97 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -21,12 +21,12 @@ + -