mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Prevent double marking as watched
Also removed the mark watched at: % setting. It is controlled by the server itself.
This commit is contained in:
parent
43494ec053
commit
7d9fe89806
5 changed files with 56 additions and 41 deletions
|
@ -23,6 +23,11 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
xbmc.Monitor.__init__(self)
|
xbmc.Monitor.__init__(self)
|
||||||
|
|
||||||
|
def logMsg(self, msg, lvl = 1):
|
||||||
|
|
||||||
|
className = self.__class__.__name__
|
||||||
|
utils.logMsg("%s %s" % ("EMBY", className), msg, int(lvl))
|
||||||
|
|
||||||
def onDatabaseUpdated(self, database):
|
def onDatabaseUpdated(self, database):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -97,20 +102,23 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
WINDOW.setProperty(playurl+"AudioStreamIndex", str(mediaSources[0].get('DefaultAudioStreamIndex')))
|
WINDOW.setProperty(playurl+"AudioStreamIndex", str(mediaSources[0].get('DefaultAudioStreamIndex')))
|
||||||
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
|
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
|
||||||
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
|
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0].get('DefaultSubtitleStreamIndex')))
|
||||||
|
|
||||||
if method == "VideoLibrary.OnUpdate":
|
if method == "VideoLibrary.OnUpdate":
|
||||||
|
# Triggers 4 times, the following is only for manually marking as watched/unwatched
|
||||||
jsondata = json.loads(data)
|
jsondata = json.loads(data)
|
||||||
if jsondata != None:
|
|
||||||
|
|
||||||
playcount = None
|
try:
|
||||||
playcount = jsondata.get("playcount")
|
playcount = jsondata['playcount']
|
||||||
item = jsondata.get("item").get("id")
|
item = jsondata['item']['id']
|
||||||
type = jsondata.get("item").get("type")
|
type = jsondata['item']['type']
|
||||||
prop = WINDOW.getProperty('Played%s%s' % (type,item))
|
prop = utils.window('Played%s%s' % (type, item))
|
||||||
processWatched = WINDOW.getProperty('played_skipWatched')
|
except:
|
||||||
|
self.logMsg("Could not process VideoLibrary.OnUpdate data.", 1)
|
||||||
if (playcount != None) and (prop != "true") and (processWatched != "true"):
|
else:
|
||||||
WINDOW.setProperty("Played%s%s" % (type,item), "true")
|
self.logMsg("VideoLibrary.OnUpdate: %s" % data, 2)
|
||||||
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
|
if prop != "true":
|
||||||
|
# Set property to prevent the multi triggering
|
||||||
|
utils.window('Played%s%s' % (type, item), "true")
|
||||||
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
|
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
|
||||||
|
|
||||||
self.clearProperty(type, item)
|
self.clearProperty(type, item)
|
||||||
|
@ -147,11 +155,9 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
|
|
||||||
def clearProperty(self, type, id):
|
def clearProperty(self, type, id):
|
||||||
# The sleep is necessary since VideoLibrary.OnUpdate
|
# The sleep is necessary since VideoLibrary.OnUpdate
|
||||||
# triggers 3 times in a row.
|
# triggers 4 times in a row.
|
||||||
xbmc.sleep(100)
|
xbmc.sleep(100)
|
||||||
self.WINDOW.clearProperty("Played%s%s" % (type,id))
|
utils.window('Played%s%s' % (type,id), clear=True)
|
||||||
self.WINDOW.clearProperty('played_skipWatched')
|
|
||||||
|
|
||||||
#clear the widget cache
|
|
||||||
self.WINDOW.setProperty('clearwidgetcache','clear')
|
|
||||||
|
|
||||||
|
# Clear the widget cache
|
||||||
|
utils.window('clearwidgetcache', value="clear")
|
|
@ -378,8 +378,8 @@ class Player( xbmc.Player ):
|
||||||
data = self.played_information.get(item)
|
data = self.played_information.get(item)
|
||||||
if data:
|
if data:
|
||||||
|
|
||||||
self.logMsg("Item path: %s" % item, 1)
|
self.logMsg("Item path: %s" % item, 2)
|
||||||
self.logMsg("Item data: %s" % str(data), 1)
|
self.logMsg("Item data: %s" % str(data), 2)
|
||||||
|
|
||||||
runtime = data.get('runtime')
|
runtime = data.get('runtime')
|
||||||
currentPosition = data.get('currentPosition')
|
currentPosition = data.get('currentPosition')
|
||||||
|
@ -390,14 +390,12 @@ class Player( xbmc.Player ):
|
||||||
playMethod = data.get('playmethod')
|
playMethod = data.get('playmethod')
|
||||||
|
|
||||||
if currentPosition and runtime:
|
if currentPosition and runtime:
|
||||||
self.logMsg("RuntimeTicks: %s" % runtime, 1)
|
|
||||||
percentComplete = (currentPosition * 10000000) / int(runtime)
|
percentComplete = (currentPosition * 10000000) / int(runtime)
|
||||||
markPlayedAt = float(utils.settings('markPlayed')) / 100
|
markPlayedAt = float(utils.settings('markPlayed')) / 100
|
||||||
|
|
||||||
self.logMsg("Percent complete: %s Mark played at: %s" % (percentComplete, markPlayedAt))
|
self.logMsg("Percent complete: %s Mark played at: %s" % (percentComplete, markPlayedAt), 1)
|
||||||
if percentComplete < markPlayedAt:
|
# Prevent manually mark as watched in Kodi monitor > WriteKodiVideoDB().UpdatePlaycountFromKodi()
|
||||||
# Do not mark as watched for Kodi Monitor
|
utils.window('SkipWatched%s' % itemId, "true")
|
||||||
utils.window('played_skipWatched', value="true")
|
|
||||||
|
|
||||||
self.stopPlayback(data)
|
self.stopPlayback(data)
|
||||||
offerDelete = False
|
offerDelete = False
|
||||||
|
@ -430,8 +428,8 @@ class Player( xbmc.Player ):
|
||||||
|
|
||||||
self.logMsg("stopPlayback called", 2)
|
self.logMsg("stopPlayback called", 2)
|
||||||
|
|
||||||
itemId = data.get('item_id')
|
itemId = data['item_id']
|
||||||
currentPosition = data.get('currentPosition')
|
currentPosition = data['currentPosition']
|
||||||
positionTicks = int(currentPosition * 10000000)
|
positionTicks = int(currentPosition * 10000000)
|
||||||
|
|
||||||
url = "{server}/mediabrowser/Sessions/Playing/Stopped"
|
url = "{server}/mediabrowser/Sessions/Playing/Stopped"
|
||||||
|
|
|
@ -184,6 +184,12 @@ class UserClient(threading.Thread):
|
||||||
# Set user image for skin display
|
# Set user image for skin display
|
||||||
self.WINDOW.setProperty("EmbyUserImage",API().getUserArtwork(result,"Primary"))
|
self.WINDOW.setProperty("EmbyUserImage",API().getUserArtwork(result,"Primary"))
|
||||||
|
|
||||||
|
# Load the resume point from Emby and set as setting
|
||||||
|
url = "{server}/mediabrowser/System/Configuration?format=json"
|
||||||
|
result = self.doUtils.downloadUrl(url)
|
||||||
|
|
||||||
|
utils.settings('markPlayed', value=str(result['MaxResumePct']))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getPublicUsers(self):
|
def getPublicUsers(self):
|
||||||
|
|
|
@ -56,6 +56,11 @@ class WriteKodiVideoDB():
|
||||||
except:
|
except:
|
||||||
# Could not find the Emby Id
|
# Could not find the Emby Id
|
||||||
self.logMsg("Emby Id not found.", 2)
|
self.logMsg("Emby Id not found.", 2)
|
||||||
|
else:
|
||||||
|
# Stop from manually marking as watched unwatched, with actual playback.
|
||||||
|
# Window property is set in Player.py
|
||||||
|
if utils.window('SkipWatched%s' % emby_id) == "true":
|
||||||
|
utils.window('SkipWatched%s' % emby_id, clear=True)
|
||||||
else:
|
else:
|
||||||
# Found the Emby Id, let Emby server know of new playcount
|
# Found the Emby Id, let Emby server know of new playcount
|
||||||
watchedurl = "{server}/mediabrowser/Users/{UserId}/PlayedItems/%s" % emby_id
|
watchedurl = "{server}/mediabrowser/Users/{UserId}/PlayedItems/%s" % emby_id
|
||||||
|
|
|
@ -36,13 +36,13 @@
|
||||||
<setting id="smbpassword" type="text" label="30008" default="" option="hidden" visible="true" enable="true" />
|
<setting id="smbpassword" type="text" label="30008" default="" option="hidden" visible="true" enable="true" />
|
||||||
<setting type="sep" />
|
<setting type="sep" />
|
||||||
<setting id="disableCinema" type="bool" label="Disable Emby cinema mode" default="false" visible="true" enable="true" />
|
<setting id="disableCinema" type="bool" label="Disable Emby cinema mode" default="false" visible="true" enable="true" />
|
||||||
<setting id="markPlayed" label="Mark watched at" type="slider" default="90" range="60,5,100" option="percent" visible="true" enable="true" />
|
|
||||||
<setting id="offerDelete" type="bool" label="30114" visible="true" enable="true" default="false" />
|
<setting id="offerDelete" type="bool" label="30114" visible="true" enable="true" default="false" />
|
||||||
<setting id="offerDeleteTV" type="bool" label="30115" visible="eq(-1,true)" enable="true" default="false" />
|
<setting id="offerDeleteTV" type="bool" label="30115" visible="eq(-1,true)" enable="true" default="false" />
|
||||||
<setting id="offerDeleteMovies" type="bool" label="30116" visible="eq(-2,true)" enable="true" default="false" />
|
<setting id="offerDeleteMovies" type="bool" label="30116" visible="eq(-2,true)" enable="true" default="false" />
|
||||||
<setting id="resumeJumpBack" type="slider" label="On Resume Jump Back Seconds" default="10" range="0,1,120" option="int" visible="true" enable="true" />
|
<setting id="resumeJumpBack" type="slider" label="On Resume Jump Back Seconds" default="10" range="0,1,120" option="int" visible="true" enable="true" />
|
||||||
<setting id="playFromStream" type="bool" label="30002" visible="true" enable="true" default="false" />
|
<setting id="playFromStream" type="bool" label="30002" visible="true" enable="true" default="false" />
|
||||||
<setting id="videoBitRate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" visible="eq(-1,true)" default="17" />
|
<setting id="videoBitRate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" visible="eq(-1,true)" default="17" />
|
||||||
|
<setting id="markPlayed" type="number" visible="false" default="90" />
|
||||||
<setting id="directSteamFailedCount" type="number" visible="false" default="0" />
|
<setting id="directSteamFailedCount" type="number" visible="false" default="0" />
|
||||||
</category>
|
</category>
|
||||||
<category label="Extras">
|
<category label="Extras">
|
||||||
|
|
Loading…
Reference in a new issue