diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 25c80998..f71e36c4 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -299,7 +299,7 @@ Server messages [COLOR yellow]Generate a new unique device Id (e.g. when cloning Kodi)[/COLOR] Users must log in every time when Kodi restarts - Restart Kodi if you make changes + RESTART KODI IF YOU MAKE ANY CHANGES Complete Re-Sync necessary @@ -393,6 +393,9 @@ On Deck: Append season- and episode-number (e.g. S3E2) Nothing works? Try a full reset! [COLOR yellow]Choose Plex Server from a list[/COLOR] + Wait before sync new/changed PMS item [s] + Background Sync + diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index c13163ef..dd928ea2 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -26,7 +26,7 @@ [COLOR yellow]Neue einzigartige Geräte-ID generieren (z.B. wenn Kodi geklont wurde)[/COLOR] Benutzer müssen sich bei jedem Neustart von Kodi neu anmelden - Bei Änderungen Kodi neu starten + BEI ÄNDERUNGEN KODI NEU STARTEN Komplette Neusynchronisierung nötig @@ -331,6 +331,8 @@ "Aktuell": Staffel und Episode anfügen (z.B. S3E2) Nichts funktioniert? Setze mal alles zurück! [COLOR yellow]Plex Server aus Liste auswählen[/COLOR] + Warten bevor neue/geänderte PMS Einträge gesynct werden [s] + Hintergrund-Synchronisation Plex Home Benutzer abmelden: diff --git a/resources/lib/PlexFunctions.py b/resources/lib/PlexFunctions.py index 4aa82ee1..d432a806 100644 --- a/resources/lib/PlexFunctions.py +++ b/resources/lib/PlexFunctions.py @@ -472,6 +472,48 @@ def GetMachineIdentifier(url): return machineIdentifier +def GetPMSStatus(token): + """ + token: Needs to be authorized with a master Plex token + (not a managed user token)! + Calls /status/sessions on currently active PMS. Returns a dict with: + + 'sessionKey': + { + 'userId': Plex ID of the user (if applicable, otherwise '') + 'username': Plex name (if applicable, otherwise '') + 'ratingKey': Unique Plex id of item being played + } + + or an empty dict. + """ + answer = {} + xml = downloadutils.DownloadUtils().downloadUrl( + "{server}" + '/status/sessions', + type="GET", + headerOptions={'X-Plex-Token': token}) + try: + xml.attrib + except AttributeError: + return answer + for item in xml: + ratingKey = item.attrib.get('ratingKey') + sessionKey = item.attrib.get('sessionKey') + userId = item.find('User') + username = '' + if userId is not None: + username = userId.attrib.get('title', '') + userId = userId.attrib.get('id', '') + else: + userId = '' + answer[sessionKey] = { + 'userId': userId, + 'username': username, + 'ratingKey': ratingKey + } + return answer + + def scrobble(ratingKey, state): """ Tells the PMS to set an item's watched state to state="watched" or diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 80d97eb4..28a41d01 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -177,7 +177,6 @@ class DownloadUtils(): def getHeader(self, authenticate=True, options={}): plx = PlexAPI.PlexAPI() if authenticate: - options['X-Plex-Token'] = self.token header = plx.getXArgsDeviceInfo(options=options) else: header = plx.getXArgsDeviceInfo(options=options) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index aadeca3a..77ab2625 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -33,24 +33,9 @@ def DateToKodi(stamp): Output: Y-m-d h:m:s = 2009-04-05 23:16:04 """ - # DATEFORMAT = xbmc.getRegion('dateshort') - # TIMEFORMAT = xbmc.getRegion('meridiem') - # date_time = time.localtime(stamp) - # if DATEFORMAT[1] == 'd': - # localdate = time.strftime('%d-%m-%Y', date_time) - # elif DATEFORMAT[1] == 'm': - # localdate = time.strftime('%m-%d-%Y', date_time) - # else: - # localdate = time.strftime('%Y-%m-%d', date_time) - # if TIMEFORMAT != '/': - # localtime = time.strftime('%I:%M%p', date_time) - # else: - # localtime = time.strftime('%H:%M', date_time) - # return localtime + ' ' + localdate + stamp = float(stamp) + float(window('kodiplextimeoffset')) try: - # DATEFORMAT = xbmc.getRegion('dateshort') - # TIMEFORMAT = xbmc.getRegion('meridiem') - date_time = time.localtime(float(stamp)) + date_time = time.localtime(stamp) localdate = time.strftime('%Y-%m-%d %H:%M:%S', date_time) except: localdate = None diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index 5004a372..365f7338 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -13,7 +13,6 @@ import xbmcgui import clientinfo import downloadutils -import librarysync import playlist import userclient import utils @@ -349,7 +348,8 @@ class WebSocket_Client(threading.Thread): userId = window('currUserId') server = window('pms_server') - token = window('pms_token') + # Need to use plex.tv token, if any + token = window('plex_token') deviceId = self.deviceId # Get the appropriate prefix for the websocket diff --git a/resources/settings.xml b/resources/settings.xml index 329175ce..5185045d 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -48,15 +48,18 @@ - - + - + + + + + diff --git a/service.py b/service.py index 4f4654cc..e88e47d0 100644 --- a/service.py +++ b/service.py @@ -85,7 +85,8 @@ class Service(): "plex_authenticated", "EmbyUserImage", "useDirectPaths", "replaceSMB", "remapSMB", "remapSMBmovieOrg", "remapSMBtvOrg", "remapSMBmusicOrg", "remapSMBmovieNew", "remapSMBtvNew", - "remapSMBmusicNew", "suspend_LibraryThread", "plex_terminateNow" + "remapSMBmusicNew", "suspend_LibraryThread", "plex_terminateNow", + "kodiplextimeoffset" ] for prop in properties: window(prop, clear=True)