Merge pull request #1039 from croneter/fix-external-player
Fix resume when using an external player
This commit is contained in:
commit
07c8a1c67d
2 changed files with 38 additions and 11 deletions
|
@ -35,7 +35,8 @@ class PlayState(object):
|
||||||
'volume': 100,
|
'volume': 100,
|
||||||
'muted': False,
|
'muted': False,
|
||||||
'playmethod': None,
|
'playmethod': None,
|
||||||
'playcount': None
|
'playcount': None,
|
||||||
|
'external_player': False # bool - xbmc.Player().isExternalPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -349,6 +349,11 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
status['plex_type'] = plex_type
|
status['plex_type'] = plex_type
|
||||||
status['playmethod'] = item.playmethod
|
status['playmethod'] = item.playmethod
|
||||||
status['playcount'] = item.playcount
|
status['playcount'] = item.playcount
|
||||||
|
try:
|
||||||
|
status['external_player'] = app.APP.player.isExternalPlayer() == 1
|
||||||
|
except AttributeError:
|
||||||
|
# Kodi version < 17
|
||||||
|
pass
|
||||||
LOG.debug('Set the player state: %s', status)
|
LOG.debug('Set the player state: %s', status)
|
||||||
if not app.SYNC.direct_paths:
|
if not app.SYNC.direct_paths:
|
||||||
_notify_upnext(item)
|
_notify_upnext(item)
|
||||||
|
@ -403,6 +408,11 @@ def _record_playstate(status, ended):
|
||||||
LOG.debug('No playstate update due to Plex id not found: %s', status)
|
LOG.debug('No playstate update due to Plex id not found: %s', status)
|
||||||
return
|
return
|
||||||
totaltime = float(timing.kodi_time_to_millis(status['totaltime'])) / 1000
|
totaltime = float(timing.kodi_time_to_millis(status['totaltime'])) / 1000
|
||||||
|
if status['external_player']:
|
||||||
|
_external_player_correct_plex_watch_count(db_item)
|
||||||
|
progress = 0.0
|
||||||
|
time = 0.0
|
||||||
|
else:
|
||||||
if ended:
|
if ended:
|
||||||
progress = 0.99
|
progress = 0.99
|
||||||
time = v.IGNORE_SECONDS_AT_START + 1
|
time = v.IGNORE_SECONDS_AT_START + 1
|
||||||
|
@ -455,6 +465,22 @@ def _record_playstate(status, ended):
|
||||||
backgroundthread.BGThreader.addTasksToFront([task])
|
backgroundthread.BGThreader.addTasksToFront([task])
|
||||||
|
|
||||||
|
|
||||||
|
def _external_player_correct_plex_watch_count(db_item):
|
||||||
|
"""
|
||||||
|
Kodi won't safe playstate at all for external players
|
||||||
|
|
||||||
|
There's currently no way to get a resumpoint if an external player is
|
||||||
|
in use We are just checking whether we should mark video as
|
||||||
|
completely watched or completely unwatched (according to
|
||||||
|
playcountminimumtime set in playercorefactory.xml)
|
||||||
|
See https://kodi.wiki/view/External_players
|
||||||
|
"""
|
||||||
|
with kodi_db.KodiVideoDB() as kodidb:
|
||||||
|
playcount = kodidb.get_playcount(db_item['kodi_fileid'])
|
||||||
|
LOG.debug('External player detected. Playcount: %s', playcount)
|
||||||
|
PF.scrobble(db_item['plex_id'], 'watched' if playcount else 'unwatched')
|
||||||
|
|
||||||
|
|
||||||
def _clean_file_table():
|
def _clean_file_table():
|
||||||
"""
|
"""
|
||||||
If we associate a playing video e.g. pointing to plugin://... to an existing
|
If we associate a playing video e.g. pointing to plugin://... to an existing
|
||||||
|
|
Loading…
Reference in a new issue