From c2ecdacec45b5830f1b2dcc969f366a34200e6e6 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Thu, 3 Mar 2016 14:00:48 +0100 Subject: [PATCH] Settings overhaul. Also added many German translations --- default.py | 20 +----- resources/language/English/strings.xml | 74 +++++++++++++++++++--- resources/language/German/strings.xml | 69 +++++++++++++++++++- resources/lib/PlexAPI.py | 42 ++++++++----- resources/lib/artwork.py | 8 ++- resources/lib/entrypoint.py | 37 ++++++----- resources/lib/initialsetup.py | 68 +++++++++----------- resources/lib/read_embyserver.py | 2 +- resources/settings.xml | 87 ++++++++++++++------------ 9 files changed, 259 insertions(+), 148 deletions(-) diff --git a/default.py b/default.py index c1b10eec..d36a29da 100644 --- a/default.py +++ b/default.py @@ -8,6 +8,7 @@ import urlparse import xbmc import xbmcaddon +import xbmcgui ################################################################################################# @@ -101,24 +102,7 @@ class Main: if mode == "settings": xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)') elif mode in ("manualsync", "repair"): - if utils.window('emby_online') != "true": - # Server is not online, do not run the sync - xbmcgui.Dialog().ok(heading="Emby for Kodi", - line1=("Unable to run the sync, the add-on is not " - "connected to the Emby server.")) - utils.logMsg("EMBY", "Not connected to the emby server.", 1) - return - - if utils.window('emby_dbScan') != "true": - import librarysync - lib = librarysync.LibrarySync() - if mode == "manualsync": - librarysync.ManualSync(dialog=True) - else: - lib.fullSync(repair=True) - else: - utils.logMsg("EMBY", "Database scan is already running.", 1) - + entrypoint.RunLibScan(mode) elif mode == "texturecache": import artwork artwork.Artwork().FullTextureCacheSync() diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 776e06a1..e58348f6 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -1,8 +1,8 @@  - Primary Server Address - Play from HTTP instead of SMB + Server Address (IP) + Deactivate Direct Play and enforce Transcoding Log level Username: Password: @@ -12,7 +12,7 @@ Enable Performance Profiling Local caching system - Emby + Connection Network Device Name @@ -213,7 +213,7 @@ Sync Extra Fanart Sync Movie BoxSets - Reset local Kodi database + [COLOR yellow]Reset local Kodi database[/COLOR] Enable watched/resume status sync DB Sync Indication: Play Count Sync Indication: @@ -262,16 +262,16 @@ Delete item from the server - Verify Host SSL Certificate + Verify Host SSL Certificate (more secure) Client SSL certificate Use alternate address Alternate Server Address - Use altername device Name - [COLOR yellow]Retry login[/COLOR] + Use alternate device Name + [COLOR yellow]Reset login attempts[/COLOR] Sync Options Show syncing progress Sync empty TV Shows - Enable Music Library + Enable Music Library (restart Kodi!) Direct stream music library Playback Mode Force artwork caching @@ -279,8 +279,8 @@ Enable fast startup (requires server plugin) Maximum items to request from the server at once Playback - Network credentials - Enable Emby cinema mode + [COLOR yellow]Enter network credentials[/COLOR] + Enable Plex Trailers (Plexpass is needed) Ask to play trailers Skip Emby delete confirmation for the context menu (use at your own risk) Jump back on resume (in seconds) @@ -335,4 +335,58 @@ Failed to generate a new device Id. See your logs for more information. A new device Id has been generated. Kodi will now restart. + + - Number of trailers to play before a movie + Boost audio when transcoding + Subtitle size when transcoding + Limit download sync threads (recommended for rpi: 1) + Enable Plex Companion + Plex Companion Port (change only if needed) + Activate Plex Companion debug log + Activate Plex Companion GDM debug log + Allows flinging media to Kodi through Plex + Could not login to plex.tv. Please try signing in again. + Problems connecting to plex.tv. Network or internet issue? + Could not find any Plex server in the network. Aborting... + Choose your Plex server + Not yet authorized for Plex server + Please sign in to plex.tv. + Problems connecting to server. Pick another server? + Disable Plex music library? + Would you now like to go to the plugin's settings? + (This is hopefully unneccessary ;-)) + + [COLOR yellow]Repair local database (force update all content)[/COLOR] + [COLOR yellow]Perform local database reset (full resync)[/COLOR] + [COLOR yellow]Cache all images to Kodi texture cache[/COLOR] + [COLOR yellow]Sync Emby Theme Media to Kodi[/COLOR] + + + Switch Plex Home User + Settings + Network credentials + Refresh Plex playlists/nodes + 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? + + + + Running the image cache process can take some time. Are you sure you want continue? + Reset all existing cache data first? + + + : Enter plex.tv username. Or nothing to cancel. + Enter password for plex.tv user + Could not sign in user + Problems trying to contact plex.tv. Try again later + Go to https://plex.tv/pin and enter the code: + + + Could not sign in to plex.tv. Try again later + : Select User + Enter PIN for user + Could not log in user + Please try again. + diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index cd9473c2..d5ca8e7d 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -2,7 +2,7 @@ IP-Adresse des Servers Automatisches Öffnen von Ordnern mit einem Eintrag - Via HTTP abspielen statt SMB/NFS: + Direct Play deaktivieren and Transkodieren erzwingen Log Level: Benutzername: Passwort: @@ -11,8 +11,21 @@ Transkodieren: Performancemessung aktivieren Caching-Mechanismus + Host SSL Zertifikat überprüfen (sicherer) + Synchronisations-Fortschritt anzeigen + Zwischenspeichern von PMS Bildern erzwingen + Plex Musik-Bibliotheken aktivieren (Kodi Neustart!) + Plex Trailer aktivieren (Plexpass benötigt) + Nachfragen, ob Trailer gespielt werden sollen + H265 Codec Transkodierung erzwingen + Netzwerk Credentials eingeben + PlexKodiConnect Start Verzögerung (in Sekunden) + Extras ignorieren, wenn Nächste Episode gespielt wird + Bei Wiederaufnahme zurückspulen (in Sekunden) + [COLOR yellow]Anzahl Login-Versuche zurücksetzen[/COLOR] - Emby + + Verbindung Netzwerk Gerätename @@ -252,4 +265,56 @@ Musikstücke Kanäle + + - Anzahl abzuspielender Trailer vor einem Film + Audio Verstärkung (audio boost) wenn transkodiert wird + Grösse des Untertitels wenn transkodiert wird + Anzahl Download Sync Threads beschränken (Empfehlung für rpi: 1) + Plex Companion aktivieren + Plex Companion Port (nur bei Bedarf ändern) + Plex Companion debug log aktivieren + Plex Companion GDM debug log aktivieren + Spiele Inhalt von anderen Plex Geräten ab + Login bei plex.tv fehlgeschlagen. Bitte erneut versuchen. + Netzwerk Verbindungsprobleme für plex.tv. Funktionieren Netzwerk und/oder Internet? + Konnte keine Plex Server im Netzwerk finden. Abbruch... + Wählen Sie Ihren Plex Server + Noch nicht authorisiert für Plex Server + Bitte loggen Sie sich in plex.tv ein. + Beim Verbinden mit dem Server sind Probleme aufgetreten. Mit einem anderen Server versuchen? + Plex Musik Bibliotheken deaktivieren? + Möchten Sie nun die Einstellungen des Plugins öffnen? (Was hoffentlich unnötig ist ;-))" + + [COLOR yellow]Lokale Datenbank reparieren (allen Inhalt aktualisieren)[/COLOR] + [COLOR yellow]Lokale Datenbank zurücksetzen (kompletter Resync nötig)[/COLOR] + [COLOR yellow]Alle Plex Bilder in Kodi zwischenspeichern[/COLOR] + [COLOR yellow]Plex Themes zu Kodi synchronisieren[/COLOR] + + + Plex Home Benutzer wechseln + Einstellungen + Netzwerk Credentials + Plex Playlisten und Nodes zurücksetzen + 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? + + + Alle Plex Bilder in Kodi zwischenzuspeichern kann sehr lange dauern. Möchten Sie wirklich fortfahren? + Sollen erst alle bestehenden Bilder im Cache gelöscht werden? + + + : plex.tv Benutzernamen eingeben. Oder nichts, um abzubrechen. + Passwort eingeben für plex.tv Benutzer + Anmeldung fehlgeschlagen für Benutzer + Probleme beim Verbinden mit plex.tv. Bitte später erneut versuchen. + https://plex.tv/pin besuchen und den folgenden Code eingeben: + + + Anmeldung bei plex.tv fehlgeschlagen. Bitte später erneut versuchen. + : Benutzer auswählen + PIN eingeben für Benutzer + Anmeldung fehlgeschlagen für Benutzer + Bitte erneut versuchen. + diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 75f38869..77682038 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -113,20 +113,23 @@ class PlexAPI(): Also writes 'plexLogin' and 'token_plex.tv' to Kodi settings file If not logged in, empty strings are returned for both. """ + string = self.__language__ + retrievedPlexLogin = '' plexLogin = 'dummy' authtoken = '' while retrievedPlexLogin == '' and plexLogin != '': dialog = xbmcgui.Dialog() + # Enter plex.tv username. Or nothing to cancel. plexLogin = dialog.input( - self.addonName + - ': Enter plex.tv username. Or nothing to cancel.', + self.addonName + string(39300), type=xbmcgui.INPUT_ALPHANUM, ) if plexLogin != "": dialog = xbmcgui.Dialog() + # Enter password for plex.tv user plexPassword = dialog.input( - 'Enter password for plex.tv user %s' % plexLogin, + string(39301) + plexLogin, type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT ) @@ -139,8 +142,8 @@ class PlexAPI(): % (plexLogin, authtoken), 1) if plexLogin == '': dialog = xbmcgui.Dialog() - dialog.ok(self.addonName, 'Could not sign in user %s' - % plexLogin) + # Could not sign in user + dialog.ok(self.addonName, string(39302) + plexLogin) # Write to Kodi settings file utils.settings('plexLogin', value=retrievedPlexLogin) utils.settings('plexToken', value=authtoken) @@ -159,16 +162,17 @@ class PlexAPI(): } Returns False if authentication did not work. """ + string = self.__language__ + code, identifier = self.GetPlexPin() dialog = xbmcgui.Dialog() if not code: - dialog.ok(self.addonName, - 'Problems trying to contact plex.tv', - 'Try again later') + # Problems trying to contact plex.tv. Try again later + dialog.ok(self.addonName, string(39303)) return False + # Go to https://plex.tv/pin and enter the code: answer = dialog.yesno(self.addonName, - 'Go to https://plex.tv/pin and enter the code:', - '', + string(39304), code) if not answer: return False @@ -182,9 +186,8 @@ class PlexAPI(): xbmc.sleep(5000) count += 1 if not xml: - dialog.ok(self.addonName, - 'Could not sign in to plex.tv', - 'Try again later') + # Could not sign in to plex.tv Try again later + dialog.ok(self.addonName, string(39305)) return False # Parse xml home = xml.get('home', '0') @@ -1043,6 +1046,8 @@ class PlexAPI(): Will return empty strings if failed. """ + string = self.__language__ + plexLogin = utils.settings('plexLogin') plexToken = utils.settings('plexToken') machineIdentifier = utils.settings('plex_machineIdentifier') @@ -1066,7 +1071,8 @@ class PlexAPI(): while trials < 3: if usernumber > 1: dialog = xbmcgui.Dialog() - user_select = dialog.select(self.addonName + ": Select User", + # Select user + user_select = dialog.select(self.addonName + string(39306), userlist) if user_select == -1: self.logMsg("No user selected.", 1) @@ -1083,8 +1089,9 @@ class PlexAPI(): # Ask for PIN, if protected: if user['protected'] == '1': dialog = xbmcgui.Dialog() + # Please enter pin for user pin = dialog.input( - 'Enter PIN for user %s' % selected_user, + string(39307) + selected_user, type=xbmcgui.INPUT_NUMERIC, option=xbmcgui.ALPHANUM_HIDE_INPUT ) @@ -1100,10 +1107,11 @@ class PlexAPI(): # Couldn't get user auth if not username: dialog = xbmcgui.Dialog() + # Could not login user, please try again dialog.ok( self.addonName, - 'Could not log in user %s' % selected_user, - 'Please try again.' + string(39308) + selected_user, + string(39309) ) # Successfully retrieved: break out of while loop else: diff --git a/resources/lib/artwork.py b/resources/lib/artwork.py index 94ba8b85..7469f503 100644 --- a/resources/lib/artwork.py +++ b/resources/lib/artwork.py @@ -159,8 +159,10 @@ class Artwork(): def FullTextureCacheSync(self): # This method will sync all Kodi artwork to textures13.db # and cache them locally. This takes diskspace! - - if not xbmcgui.Dialog().yesno("Image Texture Cache", "Running the image cache process can take some time.", "Are you sure you want continue?"): + import xbmcaddon + string = xbmcaddon.Addon().getLocalizedString + + if not xbmcgui.Dialog().yesno("Image Texture Cache", string(39250)): return self.logMsg("Doing Image Cache Sync", 1) @@ -169,7 +171,7 @@ class Artwork(): dialog.create("Emby for Kodi", "Image Cache Sync") # ask to rest all existing or not - if xbmcgui.Dialog().yesno("Image Texture Cache", "Reset all existing cache data first?", ""): + if xbmcgui.Dialog().yesno("Image Texture Cache", string(39251), ""): self.logMsg("Resetting all cache data first", 1) # Remove all existing textures first path = xbmc.translatePath("special://thumbnails/").decode('utf-8') diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 06c27d20..d0638b97 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -17,12 +17,10 @@ import artwork import utils import clientinfo import downloadutils -import librarysync import read_embyserver as embyserver import embydb_functions as embydb import playbackutils as pbutils import playutils -import PlexAPI import playlist import PlexFunctions @@ -141,11 +139,10 @@ def doPlayback(itemid, dbid): ##### DO RESET AUTH ##### def resetAuth(): # User tried login and failed too many times + string = xbmcaddon.Addon().getLocalizedString resp = xbmcgui.Dialog().yesno( - heading="Warning", - line1=( - "Plex might lock your account if you fail to log in too many times. " - "Proceed anyway?")) + heading="Warning", + line1=string(39206)) if resp == 1: utils.logMsg("PLEX", "Reset login attempts.", 1) utils.window('emby_serverStatus', value="Auth") @@ -160,6 +157,7 @@ def addDirectoryItem(label, path, folder=True): xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=folder) def doMainListing(): + string = xbmcaddon.Addon().getLocalizedString xbmcplugin.setContent(int(sys.argv[1]), 'files') # Get emby nodes from the window props embyprops = utils.window('Emby.nodes.total') @@ -182,7 +180,7 @@ def doMainListing(): # Plex user switch, if Plex home is in use if utils.settings('plexhome') == 'true': - addDirectoryItem("Switch Plex Home User", + addDirectoryItem(string(39200), "plugin://plugin.video.plexkodiconnect/" "?mode=switchuser") @@ -191,16 +189,11 @@ def doMainListing(): # addDirectoryItem("Live Tv Recordings (experimental)", "plugin://plugin.video.plexkodiconnect/?mode=browsecontent&type=recordings&folderid=root") # some extra entries for settings and stuff. TODO --> localize the labels - addDirectoryItem("Settings", "plugin://plugin.video.plexkodiconnect/?mode=settings") - addDirectoryItem("Network credentials", "plugin://plugin.video.plexkodiconnect/?mode=passwords") + addDirectoryItem(string(39201), "plugin://plugin.video.plexkodiconnect/?mode=settings") # addDirectoryItem("Add user to session", "plugin://plugin.video.plexkodiconnect/?mode=adduser") - addDirectoryItem("Refresh Plex playlists/nodes", "plugin://plugin.video.plexkodiconnect/?mode=refreshplaylist") - addDirectoryItem("Perform manual library sync", "plugin://plugin.video.plexkodiconnect/?mode=manualsync") - addDirectoryItem("Repair local database (force update all content)", "plugin://plugin.video.plexkodiconnect/?mode=repair") - addDirectoryItem("Perform local database reset (full resync)", "plugin://plugin.video.plexkodiconnect/?mode=reset") - addDirectoryItem("Cache all images to Kodi texture cache", "plugin://plugin.video.plexkodiconnect/?mode=texturecache") - addDirectoryItem("Sync Emby Theme Media to Kodi", "plugin://plugin.video.plexkodiconnect/?mode=thememedia") - + addDirectoryItem(string(39203), "plugin://plugin.video.plexkodiconnect/?mode=refreshplaylist") + addDirectoryItem(string(39204), "plugin://plugin.video.plexkodiconnect/?mode=manualsync") + xbmcplugin.endOfDirectory(int(sys.argv[1])) @@ -1127,4 +1120,14 @@ def getExtraFanArt(): utils.logMsg("EMBY", "Error getting extrafanart: %s" % e, 1) # Always do endofdirectory to prevent errors in the logs - xbmcplugin.endOfDirectory(int(sys.argv[1])) \ No newline at end of file + xbmcplugin.endOfDirectory(int(sys.argv[1])) + + +def RunLibScan(mode): + if utils.window('emby_online') != "true": + # Server is not online, do not run the sync + string = xbmcaddon.Addon().getLocalizedString + xbmcgui.Dialog().ok(heading=addonName, + line1=string(39205)) + else: + utils.window('plex_runLibScan', value='full') diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index bf78a0c6..0532a41b 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -36,6 +36,7 @@ class InitialSetup(): Check server, user, direct paths, music, direct stream if not direct path. """ + string = self.__language__ # SERVER INFO ##### self.logMsg("Initial setup called.", 0) server = self.userClient.getServer() @@ -51,10 +52,10 @@ class InitialSetup(): chk = self.plx.CheckConnection('plex.tv', plexToken) # HTTP Error: unauthorized if chk == 401: + # Could not login, please try again dialog.ok( self.addonName, - 'Could not login to plex.tv.', - 'Please try signing in again.' + string(39009) ) result = self.plx.PlexTvSignInWithPin() if result: @@ -63,8 +64,7 @@ class InitialSetup(): elif chk is False or chk >= 400: dialog.ok( self.addonName, - 'Problems connecting to plex.tv.', - 'Network or internet issue?' + string(39010) ) # If a Plex server IP has already been set, return. if server: @@ -99,8 +99,7 @@ class InitialSetup(): if len(serverlist) == 0: dialog.ok( self.addonName, - 'Could not find any Plex server in the network.' - 'Aborting...' + string(39011) ) break for server in serverlist: @@ -110,7 +109,7 @@ class InitialSetup(): else: dialoglist.append(str(server['name'])) resp = dialog.select( - 'Choose your Plex server', + string(39012), dialoglist) server = serverlist[resp] activeServer = server['machineIdentifier'] @@ -129,9 +128,8 @@ class InitialSetup(): # Unauthorized if chk == 401: dialog.ok(self.addonName, - 'Not yet authorized for Plex server %s' - % str(server['name']), - 'Please sign in to plex.tv.') + string(39013) + str(server['name']), + string(39014)) result = self.plx.PlexTvSignInWithPin() if result: plexLogin = result['username'] @@ -142,8 +140,7 @@ class InitialSetup(): # Problems connecting elif chk >= 400 or chk is False: resp = dialog.yesno(self.addonName, - 'Problems connecting to server.', - 'Pick another server?') + string(39015)) # Exit while loop if user chooses No if not resp: break @@ -169,33 +166,26 @@ class InitialSetup(): server['scheme']), 0) # ADDITIONAL PROMPTS ##### - directPaths = dialog.yesno( - heading="%s: Playback Mode" % self.addonName, - line1=( - "Caution! If you choose Native mode, you " - "will probably lose access to certain Plex " - "features."), - nolabel="Addon (Default)", - yeslabel="Native (Direct Paths)") - if directPaths: - self.logMsg("User opted to use direct paths.", 1) - utils.settings('useDirectPaths', value="1") + # directPaths = dialog.yesno( + # heading="%s: Playback Mode" % self.addonName, + # line1=( + # "Caution! If you choose Native mode, you " + # "will probably lose access to certain Plex " + # "features."), + # nolabel="Addon (Default)", + # yeslabel="Native (Direct Paths)") + # if directPaths: + # self.logMsg("User opted to use direct paths.", 1) + # utils.settings('useDirectPaths', value="1") - musicDisabled = dialog.yesno( - heading="%s: Music Library" % self.addonName, - line1="Disable Plex music library?") - if musicDisabled: + if dialog.yesno( + heading=self.addonName, + line1=string(39016)): self.logMsg("User opted to disable Plex music library.", 1) utils.settings('enableMusic', value="false") - else: - # Only prompt if the user didn't select direct paths for videos - if not directPaths: - musicAccess = dialog.yesno( - heading="%s: Music Library" % self.addonName, - line1=( - "Direct stream the music library? Select " - "this option only if you plan on listening " - "to music outside of your network.")) - if musicAccess: - self.logMsg("User opted to direct stream music.", 1) - utils.settings('streamMusic', value="true") + + if dialog.yesno( + heading=self.addonName, + line1=string(39017)): + xbmc.executebuiltin( + 'Addon.OpenSettings(plugin.video.plexkodiconnect)') diff --git a/resources/lib/read_embyserver.py b/resources/lib/read_embyserver.py index e0d55768..d92d05c7 100644 --- a/resources/lib/read_embyserver.py +++ b/resources/lib/read_embyserver.py @@ -13,7 +13,7 @@ import downloadutils @utils.logging class Read_EmbyServer(): - limitIndex = int(utils.settings('limitindex')) + # limitIndex = int(utils.settings('limitindex')) def __init__(self): diff --git a/resources/settings.xml b/resources/settings.xml index 7f19bc21..d8b26868 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -16,9 +16,9 @@ - + @@ -27,70 +27,75 @@ + + + + + + + + + - + - - - - - - + + + + + + + - - - - - + + + + + - - - + + + - + - + - - - - - - - - - - - - + - - - - - - - - + + + +