parent
74e87892d0
commit
553dff3bbb
2 changed files with 42 additions and 19 deletions
|
@ -267,12 +267,13 @@ class PlaybackUtils():
|
||||||
# Set all properties necessary for plugin path playback
|
# Set all properties necessary for plugin path playback
|
||||||
itemid = self.API.getRatingKey()
|
itemid = self.API.getRatingKey()
|
||||||
itemtype = self.API.getType()
|
itemtype = self.API.getType()
|
||||||
resume, runtime = self.API.getRuntime()
|
userdata = self.API.getUserData()
|
||||||
|
|
||||||
embyitem = "emby_%s" % playurl
|
embyitem = "emby_%s" % playurl
|
||||||
window('%s.runtime' % embyitem, value=str(runtime))
|
window('%s.runtime' % embyitem, value=str(userdata['Runtime']))
|
||||||
window('%s.type' % embyitem, value=itemtype)
|
window('%s.type' % embyitem, value=itemtype)
|
||||||
window('%s.itemid' % embyitem, value=itemid)
|
window('%s.itemid' % embyitem, value=itemid)
|
||||||
|
window('%s.playcount' % embyitem, value=str(userdata['PlayCount']))
|
||||||
|
|
||||||
# We need to keep track of playQueueItemIDs for Plex Companion
|
# We need to keep track of playQueueItemIDs for Plex Companion
|
||||||
window('plex_%s.playQueueItemID'
|
window('plex_%s.playQueueItemID'
|
||||||
|
|
|
@ -10,6 +10,8 @@ import xbmcgui
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import downloadutils
|
import downloadutils
|
||||||
|
import embydb_functions as embydb
|
||||||
|
import kodidb_functions as kodidb
|
||||||
|
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
|
||||||
|
@ -94,6 +96,10 @@ class Player(xbmc.Player):
|
||||||
refresh_id = window("%s.refreshid" % embyitem)
|
refresh_id = window("%s.refreshid" % embyitem)
|
||||||
playMethod = window("%s.playmethod" % embyitem)
|
playMethod = window("%s.playmethod" % embyitem)
|
||||||
itemType = window("%s.type" % embyitem)
|
itemType = window("%s.type" % embyitem)
|
||||||
|
try:
|
||||||
|
playcount = int(window("%s.playcount" % embyitem))
|
||||||
|
except ValueError:
|
||||||
|
playcount = 0
|
||||||
window('emby_skipWatched%s' % itemId, value="true")
|
window('emby_skipWatched%s' % itemId, value="true")
|
||||||
|
|
||||||
self.logMsg("Playing itemtype is: %s" % itemType, 1)
|
self.logMsg("Playing itemtype is: %s" % itemType, 1)
|
||||||
|
@ -217,12 +223,19 @@ class Player(xbmc.Player):
|
||||||
playQueueVersion = window('playQueueVersion')
|
playQueueVersion = window('playQueueVersion')
|
||||||
playQueueID = window('playQueueID')
|
playQueueID = window('playQueueID')
|
||||||
playQueueItemID = window('plex_%s.playQueueItemID' % currentFile)
|
playQueueItemID = window('plex_%s.playQueueItemID' % currentFile)
|
||||||
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
|
emby_dbitem = emby_db.getItem_byId(itemId)
|
||||||
|
try:
|
||||||
|
fileid = emby_dbitem[1]
|
||||||
|
except TypeError:
|
||||||
|
self.logMsg("Could not find fileid in plex db.", 1)
|
||||||
|
fileid = None
|
||||||
# Save data map for updates and position calls
|
# Save data map for updates and position calls
|
||||||
data = {
|
data = {
|
||||||
'playQueueVersion': playQueueVersion,
|
'playQueueVersion': playQueueVersion,
|
||||||
'playQueueID': playQueueID,
|
'playQueueID': playQueueID,
|
||||||
'playQueueItemID': playQueueItemID,
|
'playQueueItemID': playQueueItemID,
|
||||||
'runtime': runtime,
|
'runtime': runtime * 1000,
|
||||||
'item_id': itemId,
|
'item_id': itemId,
|
||||||
'refresh_id': refresh_id,
|
'refresh_id': refresh_id,
|
||||||
'currentfile': currentFile,
|
'currentfile': currentFile,
|
||||||
|
@ -230,11 +243,14 @@ class Player(xbmc.Player):
|
||||||
'SubtitleStreamIndex': postdata['SubtitleStreamIndex'],
|
'SubtitleStreamIndex': postdata['SubtitleStreamIndex'],
|
||||||
'playmethod': playMethod,
|
'playmethod': playMethod,
|
||||||
'Type': itemType,
|
'Type': itemType,
|
||||||
'currentPosition': int(seekTime)
|
'currentPosition': int(seekTime) * 1000,
|
||||||
|
'fileid': fileid,
|
||||||
|
'itemType': itemType,
|
||||||
|
'playcount': playcount
|
||||||
}
|
}
|
||||||
|
|
||||||
self.played_info[currentFile] = data
|
self.played_info[currentFile] = data
|
||||||
self.logMsg("ADDING_FILE: %s" % self.played_info, 1)
|
self.logMsg("ADDING_FILE: %s" % data, 1)
|
||||||
|
|
||||||
# log some playback stats
|
# log some playback stats
|
||||||
'''if(itemType != None):
|
'''if(itemType != None):
|
||||||
|
@ -423,7 +439,7 @@ class Player(xbmc.Player):
|
||||||
|
|
||||||
if self.played_info.get(currentFile):
|
if self.played_info.get(currentFile):
|
||||||
position = self.xbmcplayer.getTime()
|
position = self.xbmcplayer.getTime()
|
||||||
self.played_info[currentFile]['currentPosition'] = position
|
self.played_info[currentFile]['currentPosition'] = position * 1000
|
||||||
|
|
||||||
self.reportPlayback()
|
self.reportPlayback()
|
||||||
|
|
||||||
|
@ -484,8 +500,18 @@ class Player(xbmc.Player):
|
||||||
|
|
||||||
markPlayedAt = float(settings('markPlayed')) / 100
|
markPlayedAt = float(settings('markPlayed')) / 100
|
||||||
self.logMsg("Percent complete: %s Mark played at: %s"
|
self.logMsg("Percent complete: %s Mark played at: %s"
|
||||||
% (percentComplete, markPlayedAt), 1)
|
% (percentComplete, markPlayedAt), 1)
|
||||||
|
if currentPosition >= markPlayedAt:
|
||||||
|
# Tell Kodi that we've finished watching (Plex knows)
|
||||||
|
if (data['fileid'] is not None and
|
||||||
|
data['itemType'] in ('movie', 'episode')):
|
||||||
|
with kodidb.GetKodiDB('video') as kodi_db:
|
||||||
|
kodi_db.addPlaystate(
|
||||||
|
data['fileid'],
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
data['playcount'] + 1,
|
||||||
|
utils.DateToKodi(utils.getUnixTimestamp()))
|
||||||
# Send the delete action to the server.
|
# Send the delete action to the server.
|
||||||
offerDelete = False
|
offerDelete = False
|
||||||
|
|
||||||
|
@ -522,6 +548,8 @@ class Player(xbmc.Player):
|
||||||
'emby_%s.refreshid' % filename,
|
'emby_%s.refreshid' % filename,
|
||||||
'emby_%s.playmethod' % filename,
|
'emby_%s.playmethod' % filename,
|
||||||
'emby_%s.type' % filename,
|
'emby_%s.type' % filename,
|
||||||
|
'emby_%s.runtime' % filename,
|
||||||
|
'emby_%s.playcount' % filename,
|
||||||
'plex_%s.playQueueItemID' % filename,
|
'plex_%s.playQueueItemID' % filename,
|
||||||
'plex_%s.playlistPosition' % filename,
|
'plex_%s.playlistPosition' % filename,
|
||||||
'plex_%s.guid' % filename
|
'plex_%s.guid' % filename
|
||||||
|
@ -540,17 +568,11 @@ class Player(xbmc.Player):
|
||||||
|
|
||||||
def stopPlayback(self, data):
|
def stopPlayback(self, data):
|
||||||
self.logMsg("stopPlayback called", 1)
|
self.logMsg("stopPlayback called", 1)
|
||||||
|
|
||||||
itemId = data['item_id']
|
|
||||||
playTime = data['currentPosition']
|
|
||||||
duration = data.get('runtime', '')
|
|
||||||
|
|
||||||
url = "{server}/:/timeline?"
|
|
||||||
args = {
|
args = {
|
||||||
'ratingKey': itemId,
|
'ratingKey': data['item_id'],
|
||||||
'state': 'stopped', # 'stopped', 'paused', 'buffering', 'playing'
|
'state': 'stopped', # 'stopped', 'paused', 'buffering', 'playing'
|
||||||
'time': int(playTime),
|
'time': int(data['currentPosition']),
|
||||||
'duration': int(duration)
|
'duration': int(data.get('runtime', 0))
|
||||||
}
|
}
|
||||||
url = url + urlencode(args)
|
self.doUtils("{server}/:/timeline?" + urlencode(args),
|
||||||
self.doUtils(url, action_type="GET")
|
action_type="GET")
|
||||||
|
|
Loading…
Reference in a new issue