Fix music playlists
This commit is contained in:
parent
b00ec8989c
commit
5b4ed1d6a6
4 changed files with 18 additions and 13 deletions
|
@ -653,22 +653,22 @@ class KodiDBMethods(object):
|
||||||
WHERE strPath = ?
|
WHERE strPath = ?
|
||||||
'''
|
'''
|
||||||
self.cursor.execute(query, (path,))
|
self.cursor.execute(query, (path,))
|
||||||
path_id = self.cursor.fetchall()
|
path_ids = self.cursor.fetchall()
|
||||||
if len(path_id) != 1:
|
if len(path_ids) != 1:
|
||||||
LOG.error('Found wrong number of path ids: %s for path %s, abort',
|
LOG.error('Found wrong number of path ids: %s for path %s, abort',
|
||||||
path_id, path)
|
path_ids, path)
|
||||||
return
|
return
|
||||||
query = '''
|
query = '''
|
||||||
SELECT idSong
|
SELECT idSong
|
||||||
FROM song
|
FROM song
|
||||||
WHERE strFileName = ? AND idPath = ?
|
WHERE strFileName = ? AND idPath = ?
|
||||||
'''
|
'''
|
||||||
self.cursor.execute(query, (filename, path_id[0]))
|
self.cursor.execute(query, (filename, path_ids[0][0]))
|
||||||
song_id = self.cursor.fetchall()
|
song_ids = self.cursor.fetchall()
|
||||||
if len(song_id) != 1:
|
if len(song_ids) != 1:
|
||||||
LOG.info('Found wrong number of songs %s, abort', song_id)
|
LOG.info('Found wrong number of songs %s, abort', song_ids)
|
||||||
return
|
return
|
||||||
return song_id[0]
|
return song_ids[0][0]
|
||||||
|
|
||||||
def get_resume(self, file_id):
|
def get_resume(self, file_id):
|
||||||
"""
|
"""
|
||||||
|
@ -1200,10 +1200,11 @@ def kodiid_from_filename(path, kodi_type=None, db_type=None):
|
||||||
if kodi_type == v.KODI_TYPE_SONG or db_type == 'music':
|
if kodi_type == v.KODI_TYPE_SONG or db_type == 'music':
|
||||||
with GetKodiDB('music') as kodi_db:
|
with GetKodiDB('music') as kodi_db:
|
||||||
try:
|
try:
|
||||||
kodi_id, kodi_type = kodi_db.music_id_from_filename(filename,
|
kodi_id = kodi_db.music_id_from_filename(filename, path)
|
||||||
path)
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
LOG.debug('No Kodi audio db element found for path %s', path)
|
LOG.debug('No Kodi audio db element found for path %s', path)
|
||||||
|
else:
|
||||||
|
kodi_type = v.KODI_TYPE_SONG
|
||||||
else:
|
else:
|
||||||
with GetKodiDB('video') as kodi_db:
|
with GetKodiDB('video') as kodi_db:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -465,7 +465,7 @@ def init_plex_playlist(playlist, plex_id):
|
||||||
LOG.debug('Initializing the playlist with Plex id %s on the Plex side: %s',
|
LOG.debug('Initializing the playlist with Plex id %s on the Plex side: %s',
|
||||||
plex_id, playlist)
|
plex_id, playlist)
|
||||||
params = {
|
params = {
|
||||||
'type': playlist.type,
|
'type': v.PLEX_PLAYLIST_TYPE_FROM_KODI[playlist.type],
|
||||||
'title': playlist.plex_name,
|
'title': playlist.plex_name,
|
||||||
'smart': 0,
|
'smart': 0,
|
||||||
'uri': ('library://None/item/%s' % (urllib.quote('/library/metadata/%s'
|
'uri': ('library://None/item/%s' % (urllib.quote('/library/metadata/%s'
|
||||||
|
|
|
@ -200,13 +200,13 @@ def m3u_to_plex_ids(playlist):
|
||||||
else:
|
else:
|
||||||
# Add-on paths not working, try direct
|
# Add-on paths not working, try direct
|
||||||
kodi_id, kodi_type = kodidb.kodiid_from_filename(
|
kodi_id, kodi_type = kodidb.kodiid_from_filename(
|
||||||
playlist.kodi_path, db_type=playlist.type)
|
entry, db_type=playlist.type)
|
||||||
if not kodi_id:
|
if not kodi_id:
|
||||||
continue
|
continue
|
||||||
with plexdb.Get_Plex_DB() as plex_db:
|
with plexdb.Get_Plex_DB() as plex_db:
|
||||||
plex_id = plex_db.getItem_byKodiId(kodi_id, kodi_type)
|
plex_id = plex_db.getItem_byKodiId(kodi_id, kodi_type)
|
||||||
if plex_id:
|
if plex_id:
|
||||||
plex_ids.append(plex_id)
|
plex_ids.append(plex_id[0])
|
||||||
return plex_ids
|
return plex_ids
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,10 @@ KODI_PLAYLIST_TYPE_FROM_PLEX = {
|
||||||
PLEX_TYPE_AUDIO_PLAYLIST: KODI_TYPE_AUDIO_PLAYLIST,
|
PLEX_TYPE_AUDIO_PLAYLIST: KODI_TYPE_AUDIO_PLAYLIST,
|
||||||
PLEX_TYPE_VIDEO_PLAYLIST: KODI_TYPE_VIDEO_PLAYLIST
|
PLEX_TYPE_VIDEO_PLAYLIST: KODI_TYPE_VIDEO_PLAYLIST
|
||||||
}
|
}
|
||||||
|
PLEX_PLAYLIST_TYPE_FROM_KODI = {
|
||||||
|
KODI_TYPE_AUDIO_PLAYLIST: PLEX_TYPE_AUDIO_PLAYLIST,
|
||||||
|
KODI_TYPE_VIDEO_PLAYLIST: PLEX_TYPE_VIDEO_PLAYLIST
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# All the Plex types as communicated in the PMS xml replies
|
# All the Plex types as communicated in the PMS xml replies
|
||||||
|
|
Loading…
Reference in a new issue