Enable resume within a playqueue
This commit is contained in:
parent
5f3aa91a54
commit
0731ae0179
2 changed files with 26 additions and 0 deletions
|
@ -952,6 +952,24 @@ class Kodidb_Functions():
|
||||||
return None
|
return None
|
||||||
return int(runtime)
|
return int(runtime)
|
||||||
|
|
||||||
|
def get_resume(self, file_id):
|
||||||
|
"""
|
||||||
|
Returns the first resume point in seconds (int) if found, else None for
|
||||||
|
the Kodi file_id provided
|
||||||
|
"""
|
||||||
|
query = '''
|
||||||
|
SELECT timeInSeconds
|
||||||
|
FROM bookmark
|
||||||
|
WHERE idFile = ?
|
||||||
|
'''
|
||||||
|
self.cursor.execute(query, (file_id,))
|
||||||
|
resume = self.cursor.fetchone()
|
||||||
|
try:
|
||||||
|
resume = resume[0]
|
||||||
|
except TypeError:
|
||||||
|
resume = None
|
||||||
|
return resume
|
||||||
|
|
||||||
def addPlaystate(self, fileid, resume_seconds, total_seconds, playcount, dateplayed):
|
def addPlaystate(self, fileid, resume_seconds, total_seconds, playcount, dateplayed):
|
||||||
# Delete existing resume point
|
# Delete existing resume point
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
|
|
|
@ -11,6 +11,7 @@ from PlexAPI import API
|
||||||
from PlexFunctions import GetPlexMetadata, init_plex_playqueue
|
from PlexFunctions import GetPlexMetadata, init_plex_playqueue
|
||||||
from downloadutils import DownloadUtils as DU
|
from downloadutils import DownloadUtils as DU
|
||||||
import plexdb_functions as plexdb
|
import plexdb_functions as plexdb
|
||||||
|
import kodidb_functions as kodidb
|
||||||
import playlist_func as PL
|
import playlist_func as PL
|
||||||
import playqueue as PQ
|
import playqueue as PQ
|
||||||
from playutils import PlayUtils
|
from playutils import PlayUtils
|
||||||
|
@ -287,6 +288,13 @@ def conclude_playback(playqueue, pos):
|
||||||
playutils.audio_subtitle_prefs(listitem)
|
playutils.audio_subtitle_prefs(listitem)
|
||||||
if state.RESUME_PLAYBACK is True:
|
if state.RESUME_PLAYBACK is True:
|
||||||
state.RESUME_PLAYBACK = False
|
state.RESUME_PLAYBACK = False
|
||||||
|
if (item.offset is None and
|
||||||
|
item.plex_type not in (v.PLEX_TYPE_SONG, v.PLEX_TYPE_CLIP)):
|
||||||
|
with plexdb.Get_Plex_DB() as plex_db:
|
||||||
|
plex_dbitem = plex_db.getItem_byId(item.plex_id)
|
||||||
|
file_id = plex_dbitem[1] if plex_dbitem else None
|
||||||
|
with kodidb.GetKodiDB('video') as kodi_db:
|
||||||
|
item.offset = kodi_db.get_resume(file_id)
|
||||||
LOG.info('Resuming playback at %s', item.offset)
|
LOG.info('Resuming playback at %s', item.offset)
|
||||||
listitem.setProperty('StartOffset', str(item.offset))
|
listitem.setProperty('StartOffset', str(item.offset))
|
||||||
listitem.setProperty('resumetime', str(item.offset))
|
listitem.setProperty('resumetime', str(item.offset))
|
||||||
|
|
Loading…
Add table
Reference in a new issue