Backgroundsync using websockets
This commit is contained in:
parent
5949988b68
commit
6a2094d444
8 changed files with 61 additions and 26 deletions
|
@ -299,7 +299,7 @@
|
||||||
<string id="30534">Server messages</string>
|
<string id="30534">Server messages</string>
|
||||||
<string id="30535">[COLOR yellow]Generate a new unique device Id (e.g. when cloning Kodi)[/COLOR]</string>
|
<string id="30535">[COLOR yellow]Generate a new unique device Id (e.g. when cloning Kodi)[/COLOR]</string>
|
||||||
<string id="30536">Users must log in every time when Kodi restarts</string>
|
<string id="30536">Users must log in every time when Kodi restarts</string>
|
||||||
<string id="30537">Restart Kodi if you make changes</string>
|
<string id="30537">RESTART KODI IF YOU MAKE ANY CHANGES</string>
|
||||||
<string id="30538">Complete Re-Sync necessary</string>
|
<string id="30538">Complete Re-Sync necessary</string>
|
||||||
|
|
||||||
|
|
||||||
|
@ -393,6 +393,9 @@
|
||||||
<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>
|
<string id="39050">[COLOR yellow]Choose Plex Server from a list[/COLOR]</string>
|
||||||
|
<string id="39051">Wait before sync new/changed PMS item [s]</string>
|
||||||
|
<string id="39052">Background Sync</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Plex Entrypoint.py -->
|
<!-- Plex Entrypoint.py -->
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
<string id="30535">[COLOR yellow]Neue einzigartige Geräte-ID generieren (z.B. wenn Kodi geklont wurde)[/COLOR]</string>
|
<string id="30535">[COLOR yellow]Neue einzigartige Geräte-ID generieren (z.B. wenn Kodi geklont wurde)[/COLOR]</string>
|
||||||
<string id="30536">Benutzer müssen sich bei jedem Neustart von Kodi neu anmelden</string>
|
<string id="30536">Benutzer müssen sich bei jedem Neustart von Kodi neu anmelden</string>
|
||||||
<string id="30537">Bei Änderungen Kodi neu starten</string>
|
<string id="30537">BEI ÄNDERUNGEN KODI NEU STARTEN</string>
|
||||||
<string id="30538">Komplette Neusynchronisierung nötig</string>
|
<string id="30538">Komplette Neusynchronisierung nötig</string>
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,6 +331,8 @@
|
||||||
<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>
|
<string id="39050">[COLOR yellow]Plex Server aus Liste auswählen[/COLOR]</string>
|
||||||
|
<string id="39051">Warten bevor neue/geänderte PMS Einträge gesynct werden [s]</string>
|
||||||
|
<string id="39052">Hintergrund-Synchronisation</string>
|
||||||
|
|
||||||
<!-- Plex Entrypoint.py -->
|
<!-- Plex Entrypoint.py -->
|
||||||
<string id="39200">Plex Home Benutzer abmelden: </string>
|
<string id="39200">Plex Home Benutzer abmelden: </string>
|
||||||
|
|
|
@ -472,6 +472,48 @@ def GetMachineIdentifier(url):
|
||||||
return machineIdentifier
|
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):
|
def scrobble(ratingKey, state):
|
||||||
"""
|
"""
|
||||||
Tells the PMS to set an item's watched state to state="watched" or
|
Tells the PMS to set an item's watched state to state="watched" or
|
||||||
|
|
|
@ -177,7 +177,6 @@ class DownloadUtils():
|
||||||
def getHeader(self, authenticate=True, options={}):
|
def getHeader(self, authenticate=True, options={}):
|
||||||
plx = PlexAPI.PlexAPI()
|
plx = PlexAPI.PlexAPI()
|
||||||
if authenticate:
|
if authenticate:
|
||||||
options['X-Plex-Token'] = self.token
|
|
||||||
header = plx.getXArgsDeviceInfo(options=options)
|
header = plx.getXArgsDeviceInfo(options=options)
|
||||||
else:
|
else:
|
||||||
header = plx.getXArgsDeviceInfo(options=options)
|
header = plx.getXArgsDeviceInfo(options=options)
|
||||||
|
|
|
@ -33,24 +33,9 @@ def DateToKodi(stamp):
|
||||||
|
|
||||||
Output: Y-m-d h:m:s = 2009-04-05 23:16:04
|
Output: Y-m-d h:m:s = 2009-04-05 23:16:04
|
||||||
"""
|
"""
|
||||||
# DATEFORMAT = xbmc.getRegion('dateshort')
|
stamp = float(stamp) + float(window('kodiplextimeoffset'))
|
||||||
# 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
|
|
||||||
try:
|
try:
|
||||||
# DATEFORMAT = xbmc.getRegion('dateshort')
|
date_time = time.localtime(stamp)
|
||||||
# TIMEFORMAT = xbmc.getRegion('meridiem')
|
|
||||||
date_time = time.localtime(float(stamp))
|
|
||||||
localdate = time.strftime('%Y-%m-%d %H:%M:%S', date_time)
|
localdate = time.strftime('%Y-%m-%d %H:%M:%S', date_time)
|
||||||
except:
|
except:
|
||||||
localdate = None
|
localdate = None
|
||||||
|
|
|
@ -13,7 +13,6 @@ import xbmcgui
|
||||||
|
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import librarysync
|
|
||||||
import playlist
|
import playlist
|
||||||
import userclient
|
import userclient
|
||||||
import utils
|
import utils
|
||||||
|
@ -349,7 +348,8 @@ class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
userId = window('currUserId')
|
userId = window('currUserId')
|
||||||
server = window('pms_server')
|
server = window('pms_server')
|
||||||
token = window('pms_token')
|
# Need to use plex.tv token, if any
|
||||||
|
token = window('plex_token')
|
||||||
deviceId = self.deviceId
|
deviceId = self.deviceId
|
||||||
|
|
||||||
# Get the appropriate prefix for the websocket
|
# Get the appropriate prefix for the websocket
|
||||||
|
|
|
@ -48,15 +48,18 @@
|
||||||
</category>
|
</category>
|
||||||
<category label="30506"><!-- Sync Options -->
|
<category label="30506"><!-- Sync Options -->
|
||||||
<setting type="lsep" label="30537" /><!-- Restart if you make changes -->
|
<setting type="lsep" label="30537" /><!-- Restart if you make changes -->
|
||||||
<setting id="enableBackgroundSync" type="bool" label="39026" default="true" visible="true"/>
|
<setting id="syncEmptyShows" type="bool" label="30508" default="false" visible="false"/>
|
||||||
<setting id="serverSync" type="bool" label="30514" default="true" visible="false"/><!-- Enable fast startup (requires server plugin) -->
|
|
||||||
<setting id="dbSyncIndicator" label="30507" type="bool" default="true" />
|
<setting id="dbSyncIndicator" label="30507" type="bool" default="true" />
|
||||||
<setting type="sep" /><!-- show syncing progress -->
|
<setting type="sep" /><!-- show syncing progress -->
|
||||||
<setting id="limitindex" type="number" label="30515" default="200" option="int" /><!-- Maximum items to request from the server at once -->
|
<setting id="limitindex" type="number" label="30515" default="200" option="int" /><!-- Maximum items to request from the server at once -->
|
||||||
<setting id="enableTextureCache" label="30512" type="bool" default="true" /> <!-- Force Artwork Caching -->
|
<setting id="enableTextureCache" label="30512" type="bool" default="true" /> <!-- Force Artwork Caching -->
|
||||||
<setting id="imageCacheLimit" type="enum" label="30513" values="Disabled|5|10|15|20|25" default="5" visible="eq(-1,true)" subsetting="true" /> <!-- Limit artwork cache threads -->
|
<setting id="imageCacheLimit" type="enum" label="30513" values="Disabled|5|10|15|20|25" default="5" visible="eq(-1,true)" subsetting="true" /> <!-- Limit artwork cache threads -->
|
||||||
<setting id="syncThreadNumber" type="slider" label="39003" default="5" option="int" range="1,1,20"/>
|
<setting id="syncThreadNumber" type="slider" label="39003" default="5" option="int" range="1,1,20"/>
|
||||||
<setting id="syncEmptyShows" type="bool" label="30508" default="false" visible="false"/>
|
<setting id="serverSync" type="bool" label="30514" default="true" visible="false"/><!-- Enable fast startup (requires server plugin) -->
|
||||||
|
|
||||||
|
<setting type="lsep" label="39052" /><!-- Background Sync -->
|
||||||
|
<setting id="enableBackgroundSync" type="bool" label="39026" default="true" visible="true"/>
|
||||||
|
<setting id="saftyMargin" type="slider" label="39051" default="30" option="int" range="10,1,300" visible="eq(-1,true)"/>
|
||||||
|
|
||||||
<setting type="lsep" label="30538" /><!-- Complete Re-Sync necessary -->
|
<setting type="lsep" label="30538" /><!-- Complete Re-Sync necessary -->
|
||||||
<setting id="enableMusic" type="bool" label="30509" default="true" />
|
<setting id="enableMusic" type="bool" label="30509" default="true" />
|
||||||
|
|
|
@ -85,7 +85,8 @@ class Service():
|
||||||
"plex_authenticated", "EmbyUserImage", "useDirectPaths",
|
"plex_authenticated", "EmbyUserImage", "useDirectPaths",
|
||||||
"replaceSMB", "remapSMB", "remapSMBmovieOrg", "remapSMBtvOrg",
|
"replaceSMB", "remapSMB", "remapSMBmovieOrg", "remapSMBtvOrg",
|
||||||
"remapSMBmusicOrg", "remapSMBmovieNew", "remapSMBtvNew",
|
"remapSMBmusicOrg", "remapSMBmovieNew", "remapSMBtvNew",
|
||||||
"remapSMBmusicNew", "suspend_LibraryThread", "plex_terminateNow"
|
"remapSMBmusicNew", "suspend_LibraryThread", "plex_terminateNow",
|
||||||
|
"kodiplextimeoffset"
|
||||||
]
|
]
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
window(prop, clear=True)
|
window(prop, clear=True)
|
||||||
|
|
Loading…
Reference in a new issue