Merge pull request #1728 from croneter/py3-fix-playqueue-order

Fix detection of playqueue order. Thus fix PKC reporting back the playing of an old episode when using UpNext
This commit is contained in:
croneter 2021-12-05 14:42:41 +01:00 committed by GitHub
commit d1c18b659b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,8 +66,7 @@ def compare_playqueues(playqueue, new_kodi_playqueue):
# Kodi exit # Kodi exit
return return
try: try:
if (old_item.file.startswith('plugin://') and if (old_item.file.startswith('plugin://') and not old_item.file.startswith(PLUGIN)):
not old_item.file.startswith(PLUGIN)):
# Ignore media by other addons # Ignore media by other addons
continue continue
except AttributeError: except AttributeError:
@ -85,18 +84,18 @@ def compare_playqueues(playqueue, new_kodi_playqueue):
else: else:
identical = plex_id == old_item.plex_id identical = plex_id == old_item.plex_id
if j == 0 and identical: if j == 0 and identical:
del old[j], index[j] del old[0], index[0]
break break
elif identical: elif identical:
log.debug('Playqueue item %s moved to position %s', log.debug('Playqueue item %s moved to position %s',
i + j, i) index[j], i)
try: try:
PL.move_playlist_item(playqueue, i + j, i) PL.move_playlist_item(playqueue, index[j], i)
except exceptions.PlaylistError: except exceptions.PlaylistError:
log.error('Could not modify playqueue positions') log.error('Could not modify playqueue positions')
log.error('This is likely caused by mixing audio and ' log.error('This is likely caused by mixing audio and '
'video tracks in the Kodi playqueue') 'video tracks in the Kodi playqueue')
del old[j], index[j] del old[j], index[i]
break break
else: else:
log.debug('Detected new Kodi element at position %s: %s ', log.debug('Detected new Kodi element at position %s: %s ',