Check for adding playQueue item via JSON API
This commit is contained in:
parent
b16055eef6
commit
48da925324
2 changed files with 22 additions and 17 deletions
|
@ -295,18 +295,18 @@ class PlaybackUtils():
|
||||||
else:
|
else:
|
||||||
with Get_Plex_DB() as plex_db:
|
with Get_Plex_DB() as plex_db:
|
||||||
db_item = plex_db.getItem_byId(api.getRatingKey())
|
db_item = plex_db.getItem_byId(api.getRatingKey())
|
||||||
try:
|
if db_item is not None:
|
||||||
add_item_to_kodi_playlist(self.playqueue,
|
if add_item_to_kodi_playlist(self.playqueue,
|
||||||
self.currentPosition,
|
self.currentPosition,
|
||||||
kodi_id=db_item[0],
|
kodi_id=db_item[0],
|
||||||
kodi_type=db_item[4])
|
kodi_type=db_item[4]) is True:
|
||||||
self.currentPosition += 1
|
self.currentPosition += 1
|
||||||
if len(item[0]) > 1:
|
if len(item[0]) > 1:
|
||||||
self.add_part(item,
|
self.add_part(item,
|
||||||
api,
|
api,
|
||||||
db_item[0],
|
db_item[0],
|
||||||
db_item[4])
|
db_item[4])
|
||||||
except TypeError:
|
else:
|
||||||
# Item not in Kodi DB
|
# Item not in Kodi DB
|
||||||
self.add_trailer(item)
|
self.add_trailer(item)
|
||||||
self.playqueue.items[self.currentPosition - 1].ID = item.get(
|
self.playqueue.items[self.currentPosition - 1].ID = item.get(
|
||||||
|
|
|
@ -337,9 +337,9 @@ def add_item_to_PMS_playlist(playlist, pos, plex_id=None, kodi_item=None):
|
||||||
def add_item_to_kodi_playlist(playlist, pos, kodi_id=None, kodi_type=None,
|
def add_item_to_kodi_playlist(playlist, pos, kodi_id=None, kodi_type=None,
|
||||||
file=None):
|
file=None):
|
||||||
"""
|
"""
|
||||||
Adds an item to the KODI playlist only
|
Adds an item to the KODI playlist only. WILL ALSO UPDATE OUR PLAYLISTS
|
||||||
|
|
||||||
WILL ALSO UPDATE OUR PLAYLISTS
|
Returns False if unsuccessful
|
||||||
"""
|
"""
|
||||||
log.debug('Adding new item kodi_id: %s, kodi_type: %s, file: %s to Kodi '
|
log.debug('Adding new item kodi_id: %s, kodi_type: %s, file: %s to Kodi '
|
||||||
'only at position %s for %s'
|
'only at position %s for %s'
|
||||||
|
@ -352,9 +352,14 @@ def add_item_to_kodi_playlist(playlist, pos, kodi_id=None, kodi_type=None,
|
||||||
params['item'] = {'%sid' % kodi_type: int(kodi_id)}
|
params['item'] = {'%sid' % kodi_type: int(kodi_id)}
|
||||||
else:
|
else:
|
||||||
params['item'] = {'file': file}
|
params['item'] = {'file': file}
|
||||||
log.debug(JSONRPC('Playlist.Insert').execute(params))
|
reply = JSONRPC('Playlist.Insert').execute(params)
|
||||||
playlist.items.insert(pos, playlist_item_from_kodi(
|
if reply.get('error') is not None:
|
||||||
{'id': kodi_id, 'type': kodi_type, 'file': file}))
|
log.error('Could not add item to playlist. Kodi reply. %s' % reply)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
playlist.items.insert(pos, playlist_item_from_kodi(
|
||||||
|
{'id': kodi_id, 'type': kodi_type, 'file': file}))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def move_playlist_item(playlist, before_pos, after_pos):
|
def move_playlist_item(playlist, before_pos, after_pos):
|
||||||
|
|
Loading…
Add table
Reference in a new issue