Revert "Another attempt to fix episode resume from widgets"

This reverts commit 04044ac896.
This commit is contained in:
croneter 2018-05-26 17:28:17 +02:00
parent 04044ac896
commit ac7b7bb96d
6 changed files with 43 additions and 74 deletions

View file

@ -428,8 +428,6 @@ class API(object):
provider = provider[0] provider = provider[0]
except IndexError: except IndexError:
provider = None provider = None
if provider and self.plex_type() == v.PLEX_TYPE_EPISODE:
provider = provider.replace('/', '')
return provider return provider
def titles(self): def titles(self):
@ -502,8 +500,8 @@ class API(object):
resume = float(self.item.attrib['viewOffset']) resume = float(self.item.attrib['viewOffset'])
except (KeyError, ValueError): except (KeyError, ValueError):
resume = 0.0 resume = 0.0
runtime = runtime * v.PLEX_TO_KODI_TIMEFACTOR runtime = int(runtime * v.PLEX_TO_KODI_TIMEFACTOR)
resume = resume * v.PLEX_TO_KODI_TIMEFACTOR resume = int(resume * v.PLEX_TO_KODI_TIMEFACTOR)
return resume, runtime return resume, runtime
def content_rating(self): def content_rating(self):
@ -533,14 +531,9 @@ class API(object):
def premiere_date(self): def premiere_date(self):
""" """
Returns the "originallyAvailableAt". If no time is present, 11pm will be Returns the "originallyAvailableAt" or None
set. Example: string "2017-02-01 23:00:00"
Returns None if not found
""" """
date = self.item.get('originallyAvailableAt') return self.item.get('originallyAvailableAt')
if date and len(date) == 10:
date = '%s 23:00:00' % date
return date
def music_studio(self): def music_studio(self):
""" """

View file

@ -555,14 +555,13 @@ def getOnDeck(viewid, mediatype, tagname, limit):
if directpaths: if directpaths:
url = api.file_path(force_first_media=True) url = api.file_path(force_first_media=True)
else: else:
url = ('plugin://%s.tvshows/%s/?plex_id=%s&plex_type=%s&mode=play&filename=%s' url = ('plugin://%s.tvshows/?plex_id=%s&plex_type=%s&mode=play&filename=%s'
% (v.ADDON_ID, % (v.ADDON_ID,
api.grandparent_id(),
api.plex_id(), api.plex_id(),
api.plex_type(), api.plex_type(),
api.file_name(force_first_media=True))) api.file_name(force_first_media=True)))
# if api.resume_point(): if api.resume_point():
# listitem.setProperty('resumetime', str(api.resume_point())) listitem.setProperty('resumetime', str(api.resume_point()))
xbmcplugin.addDirectoryItem( xbmcplugin.addDirectoryItem(
handle=HANDLE, handle=HANDLE,
url=url, url=url,

View file

@ -584,9 +584,10 @@ class TVShows(Items):
# Set plugin path # Set plugin path
toplevelpath = "plugin://%s.tvshows/" % v.ADDON_ID toplevelpath = "plugin://%s.tvshows/" % v.ADDON_ID
path = "%s%s/" % (toplevelpath, itemid) path = "%s%s/" % (toplevelpath, itemid)
toppathid = None toppathid = self.kodi_db.get_path(toplevelpath)
pathid = self.kodi_db.add_video_path(path, pathid = self.kodi_db.add_video_path(path,
date_added=api.date_created(),
id_parent_path=toppathid) id_parent_path=toppathid)
# UPDATE THE TVSHOW ##### # UPDATE THE TVSHOW #####
if update_item: if update_item:
@ -891,13 +892,13 @@ class TVShows(Items):
UPDATE episode UPDATE episode
SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?,
c10 = ?, c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, c10 = ?, c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?,
c19 = ?, idFile=?, idSeason = ?, c18 = ?, c19 = ?, idFile=?, idSeason = ?,
userrating = ? userrating = ?
WHERE idEpisode = ? WHERE idEpisode = ?
''' '''
kodicursor.execute(query, (title, plot, ratingid, writer, kodicursor.execute(query, (title, plot, ratingid, writer,
premieredate, runtime, director, season, episode, title, premieredate, runtime, director, season, episode, title,
None, None, pathid, airs_before_season, airs_before_episode, playurl, pathid,
fileid, seasonid, userdata['UserRating'], episodeid)) fileid, seasonid, userdata['UserRating'], episodeid))
else: else:
# Kodi Jarvis # Kodi Jarvis
@ -910,7 +911,7 @@ class TVShows(Items):
''' '''
kodicursor.execute(query, (title, plot, rating, writer, kodicursor.execute(query, (title, plot, rating, writer,
premieredate, runtime, director, season, episode, title, premieredate, runtime, director, season, episode, title,
None, None, playurl, pathid, airs_before_season, airs_before_episode, playurl, pathid,
fileid, seasonid, episodeid)) fileid, seasonid, episodeid))
# Update parentid reference # Update parentid reference
plex_db.updateParentId(itemid, seasonid) plex_db.updateParentId(itemid, seasonid)
@ -939,16 +940,16 @@ class TVShows(Items):
"tvdb") "tvdb")
query = ''' query = '''
INSERT INTO episode( idEpisode, idFile, c00, c01, c03, c04, INSERT INTO episode( idEpisode, idFile, c00, c01, c03, c04,
c05, c09, c10, c12, c13, c14, idShow, c15, c16, c05, c09, c10, c12, c13, c14, idShow, c15, c16, c18,
idSeason, userrating) c19, idSeason, userrating)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?) ?, ?)
''' '''
kodicursor.execute(query, (episodeid, fileid, title, plot, kodicursor.execute(query, (episodeid, fileid, title, plot,
uniqueid, '', premieredate, runtime, director, season, rating_id, writer, premieredate, runtime, director, season,
episode, title, showid, None, episode, title, showid, airs_before_season,
None, seasonid, airs_before_episode, playurl, pathid, seasonid,
None)) userdata['UserRating']))
else: else:
# Kodi Jarvis # Kodi Jarvis
query = ''' query = '''
@ -960,8 +961,8 @@ class TVShows(Items):
''' '''
kodicursor.execute(query, (episodeid, fileid, title, plot, kodicursor.execute(query, (episodeid, fileid, title, plot,
rating, writer, premieredate, runtime, director, season, rating, writer, premieredate, runtime, director, season,
episode, title, showid, None, episode, title, showid, airs_before_season,
None, playurl, pathid, seasonid)) airs_before_episode, playurl, pathid, seasonid))
# Create or update the reference in plex table Add reference is # Create or update the reference in plex table Add reference is
# idempotent; the call here updates also fileid and pathid when item is # idempotent; the call here updates also fileid and pathid when item is
@ -984,22 +985,6 @@ class TVShows(Items):
kodicursor) kodicursor)
streams = api.mediastreams() streams = api.mediastreams()
self.kodi_db.modify_streams(fileid, streams, runtime) self.kodi_db.modify_streams(fileid, streams, runtime)
if resume:
self.kodi_db.addPlaystate(fileid,
resume,
runtime,
playcount,
dateplayed)
filename = api.file_name(force_first_media=True)
path = 'plugin://%s.tvshows/' % v.ADDON_ID
filename = ('%s%s/?plex_id=%s&plex_type=%s&mode=play&filename=%s'
% (path, series_id, itemid, v.PLEX_TYPE_EPISODE, filename))
# Root path tvshows/ already saved in Kodi DB
pathid = self.kodi_db.add_video_path(path)
# add/retrieve pathid and fileid
# if the path or file already exists, the calls return current value
fileid = self.kodi_db.add_file(filename, pathid, dateadded)
LOG.debug('pathid: %s, fileid: %s', pathid, fileid)
self.kodi_db.addPlaystate(fileid, self.kodi_db.addPlaystate(fileid,
resume, resume,
runtime, runtime,

View file

@ -78,7 +78,7 @@ class KodiDBMethods(object):
'movies', 'movies',
'metadata.local', 'metadata.local',
1, 1,
None)) 0))
# And TV shows # And TV shows
path_id = self.get_path('plugin://%s.tvshows/' % v.ADDON_ID) path_id = self.get_path('plugin://%s.tvshows/' % v.ADDON_ID)
if path_id is None: if path_id is None:
@ -98,7 +98,7 @@ class KodiDBMethods(object):
'tvshows', 'tvshows',
'metadata.local', 'metadata.local',
1, 1,
None)) 0))
def parent_path_id(self, path): def parent_path_id(self, path):
""" """
@ -147,12 +147,12 @@ class KodiDBMethods(object):
pathid = self.cursor.fetchone()[0] + 1 pathid = self.cursor.fetchone()[0] + 1
query = ''' query = '''
INSERT INTO path(idPath, strPath, dateAdded, idParentPath, INSERT INTO path(idPath, strPath, dateAdded, idParentPath,
strContent, strScraper, noUpdate, exclude) strContent, strScraper, noUpdate)
VALUES (?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
''' '''
self.cursor.execute(query, self.cursor.execute(query,
(pathid, path, date_added, id_parent_path, (pathid, path, date_added, id_parent_path,
content, scraper, 1, None)) content, scraper, 1))
return pathid return pathid
def add_music_path(self, path, strHash=None): def add_music_path(self, path, strHash=None):
@ -733,9 +733,9 @@ class KodiDBMethods(object):
file_id, file_id,
resume_seconds, resume_seconds,
total_seconds, total_seconds,
None, '',
'DVDPlayer', 'VideoPlayer',
None, '',
1)) 1))
def createTag(self, name): def createTag(self, name):

View file

@ -465,11 +465,11 @@ def _playback_cleanup(ended=False):
DU().downloadUrl( DU().downloadUrl(
'{server}/video/:/transcode/universal/stop', '{server}/video/:/transcode/universal/stop',
parameters={'session': v.PKC_MACHINE_IDENTIFIER}) parameters={'session': v.PKC_MACHINE_IDENTIFIER})
# if playerid == 1: if playerid == 1:
# Bookmarks might not be pickup up correctly, so let's do them # Bookmarks might not be pickup up correctly, so let's do them
# manually. Applies to addon paths, but direct paths might have # manually. Applies to addon paths, but direct paths might have
# started playback via PMS # started playback via PMS
# _record_playstate(status, ended) _record_playstate(status, ended)
# Reset the player's status # Reset the player's status
state.PLAYER_STATES[playerid] = copy.deepcopy(state.PLAYSTATE) state.PLAYER_STATES[playerid] = copy.deepcopy(state.PLAYSTATE)
# As all playback has halted, reset the players that have been active # As all playback has halted, reset the players that have been active
@ -531,7 +531,7 @@ def _record_playstate(status, ended):
xbmc.executebuiltin('ReloadSkin()') xbmc.executebuiltin('ReloadSkin()')
thread = Thread(target=_clean_file_table) thread = Thread(target=_clean_file_table)
thread.setDaemon(True) thread.setDaemon(True)
# thread.start() thread.start()
def _clean_file_table(): def _clean_file_table():

View file

@ -241,14 +241,6 @@ def _prep_playlist_stack(xml):
api.set_part_number(part) api.set_part_number(part)
if kodi_id is None: if kodi_id is None:
# Need to redirect again to PKC to conclude playback # Need to redirect again to PKC to conclude playback
if api.plex_type() == v.PLEX_TYPE_EPISODE:
path = ('plugin://%s/%s/?plex_id=%s&plex_type=%s&mode=play&filename=%s'
% (v.ADDON_TYPE[api.plex_type()],
api.grandparent_id(),
api.plex_id(),
api.plex_type(),
api.file_name(force_first_media=True)))
else:
path = ('plugin://%s/?plex_id=%s&plex_type=%s&mode=play&filename=%s' path = ('plugin://%s/?plex_id=%s&plex_type=%s&mode=play&filename=%s'
% (v.ADDON_TYPE[api.plex_type()], % (v.ADDON_TYPE[api.plex_type()],
api.plex_id(), api.plex_id(),