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

View file

@ -555,14 +555,13 @@ def getOnDeck(viewid, mediatype, tagname, limit):
if directpaths:
url = api.file_path(force_first_media=True)
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,
api.grandparent_id(),
api.plex_id(),
api.plex_type(),
api.file_name(force_first_media=True)))
# if api.resume_point():
# listitem.setProperty('resumetime', str(api.resume_point()))
if api.resume_point():
listitem.setProperty('resumetime', str(api.resume_point()))
xbmcplugin.addDirectoryItem(
handle=HANDLE,
url=url,

View file

@ -584,9 +584,10 @@ class TVShows(Items):
# Set plugin path
toplevelpath = "plugin://%s.tvshows/" % v.ADDON_ID
path = "%s%s/" % (toplevelpath, itemid)
toppathid = None
toppathid = self.kodi_db.get_path(toplevelpath)
pathid = self.kodi_db.add_video_path(path,
date_added=api.date_created(),
id_parent_path=toppathid)
# UPDATE THE TVSHOW #####
if update_item:
@ -891,13 +892,13 @@ class TVShows(Items):
UPDATE episode
SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?,
c10 = ?, c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?,
c19 = ?, idFile=?, idSeason = ?,
c18 = ?, c19 = ?, idFile=?, idSeason = ?,
userrating = ?
WHERE idEpisode = ?
'''
kodicursor.execute(query, (title, plot, ratingid, writer,
premieredate, runtime, director, season, episode, title,
None, None, pathid,
airs_before_season, airs_before_episode, playurl, pathid,
fileid, seasonid, userdata['UserRating'], episodeid))
else:
# Kodi Jarvis
@ -910,7 +911,7 @@ class TVShows(Items):
'''
kodicursor.execute(query, (title, plot, rating, writer,
premieredate, runtime, director, season, episode, title,
None, None, playurl, pathid,
airs_before_season, airs_before_episode, playurl, pathid,
fileid, seasonid, episodeid))
# Update parentid reference
plex_db.updateParentId(itemid, seasonid)
@ -939,16 +940,16 @@ class TVShows(Items):
"tvdb")
query = '''
INSERT INTO episode( idEpisode, idFile, c00, c01, c03, c04,
c05, c09, c10, c12, c13, c14, idShow, c15, c16,
idSeason, userrating)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?)
c05, c09, c10, c12, c13, c14, idShow, c15, c16, c18,
c19, idSeason, userrating)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?)
'''
kodicursor.execute(query, (episodeid, fileid, title, plot,
uniqueid, '', premieredate, runtime, director, season,
episode, title, showid, None,
None, seasonid,
None))
rating_id, writer, premieredate, runtime, director, season,
episode, title, showid, airs_before_season,
airs_before_episode, playurl, pathid, seasonid,
userdata['UserRating']))
else:
# Kodi Jarvis
query = '''
@ -960,8 +961,8 @@ class TVShows(Items):
'''
kodicursor.execute(query, (episodeid, fileid, title, plot,
rating, writer, premieredate, runtime, director, season,
episode, title, showid, None,
None, playurl, pathid, seasonid))
episode, title, showid, airs_before_season,
airs_before_episode, playurl, pathid, seasonid))
# Create or update the reference in plex table Add reference is
# idempotent; the call here updates also fileid and pathid when item is
@ -984,22 +985,6 @@ class TVShows(Items):
kodicursor)
streams = api.mediastreams()
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,
resume,
runtime,

View file

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

View file

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

View file

@ -241,14 +241,6 @@ def _prep_playlist_stack(xml):
api.set_part_number(part)
if kodi_id is None:
# 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'
% (v.ADDON_TYPE[api.plex_type()],
api.plex_id(),