Fix monitor's playlist.onadd

This commit is contained in:
croneter 2019-04-06 12:34:27 +02:00
parent 4a3b38f5b6
commit c0035c84a6

View file

@ -178,26 +178,19 @@ class KodiMonitor(xbmc.Monitor):
backgroundthread.BGThreader.addTasksToFront([task]) backgroundthread.BGThreader.addTasksToFront([task])
def _playlist_onadd(self, data): def _playlist_onadd(self, data):
""" '''
Called if an item is added to a Kodi playlist. Example data dict: Detect widget playback. Widget for some reason, use audio playlists.
{ '''
u'item': { if data['position'] == 0:
u'type': u'movie', if data['playlistid'] == 0:
u'id': 2}, utils.window('plex.playlist.audio', value='true')
u'playlistid': 1, else:
u'position': 0 utils.window('plex.playlist.audio', clear=True)
} self.playlistid = data['playlistid']
Will NOT be called if playback initiated by Kodi widgets if utils.window('plex.playlist.start') and data['position'] == int(utils.window('plex.playlist.start')) + 1:
""" LOG.info('Playlist ready')
if 'id' not in data['item']: utils.window('plex.playlist.ready', value='true')
return utils.window('plex.playlist.start', clear=True)
old = app.PLAYSTATE.old_player_states[data['playlistid']]
if (not app.SYNC.direct_paths and
data['position'] == 0 and data['playlistid'] == 1 and
not PQ.PLAYQUEUES[data['playlistid']].items and
data['item']['type'] == old['kodi_type'] and
data['item']['id'] == old['kodi_id']):
self.hack_replay = data['item']
def _playlist_onremove(self, data): def _playlist_onremove(self, data):
""" """
@ -449,23 +442,6 @@ def _playback_cleanup(ended=False):
app.PLAYSTATE.active_players = set() app.PLAYSTATE.active_players = set()
LOG.info('Finished PKC playback cleanup') LOG.info('Finished PKC playback cleanup')
def Playlist_OnAdd(self, server, data, *args, **kwargs):
'''
Detect widget playback. Widget for some reason, use audio playlists.
'''
LOG.debug('Playlist_OnAdd: %s, %s', server, data)
if data['position'] == 0:
if data['playlistid'] == 0:
utils.window('plex.playlist.audio', value='true')
else:
utils.window('plex.playlist.audio', clear=True)
self.playlistid = data['playlistid']
if utils.window('plex.playlist.start') and data['position'] == int(utils.window('plex.playlist.start')) + 1:
LOG.info("--[ playlist ready ]")
utils.window('plex.playlist.ready', value='true')
utils.window('plex.playlist.start', clear=True)
def _record_playstate(status, ended): def _record_playstate(status, ended):
if not status['plex_id']: if not status['plex_id']: