diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index c218f842..0f77b962 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -653,22 +653,22 @@ class KodiDBMethods(object): WHERE strPath = ? ''' self.cursor.execute(query, (path,)) - path_id = self.cursor.fetchall() - if len(path_id) != 1: + path_ids = self.cursor.fetchall() + if len(path_ids) != 1: LOG.error('Found wrong number of path ids: %s for path %s, abort', - path_id, path) + path_ids, path) return query = ''' SELECT idSong FROM song WHERE strFileName = ? AND idPath = ? ''' - self.cursor.execute(query, (filename, path_id[0])) - song_id = self.cursor.fetchall() - if len(song_id) != 1: - LOG.info('Found wrong number of songs %s, abort', song_id) + self.cursor.execute(query, (filename, path_ids[0][0])) + song_ids = self.cursor.fetchall() + if len(song_ids) != 1: + LOG.info('Found wrong number of songs %s, abort', song_ids) return - return song_id[0] + return song_ids[0][0] 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': with GetKodiDB('music') as kodi_db: try: - kodi_id, kodi_type = kodi_db.music_id_from_filename(filename, - path) + kodi_id = kodi_db.music_id_from_filename(filename, path) except TypeError: LOG.debug('No Kodi audio db element found for path %s', path) + else: + kodi_type = v.KODI_TYPE_SONG else: with GetKodiDB('video') as kodi_db: try: diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 344f4b16..2cdec333 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -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', plex_id, playlist) params = { - 'type': playlist.type, + 'type': v.PLEX_PLAYLIST_TYPE_FROM_KODI[playlist.type], 'title': playlist.plex_name, 'smart': 0, 'uri': ('library://None/item/%s' % (urllib.quote('/library/metadata/%s' diff --git a/resources/lib/playlists.py b/resources/lib/playlists.py index 078a6098..0587cbc1 100644 --- a/resources/lib/playlists.py +++ b/resources/lib/playlists.py @@ -200,13 +200,13 @@ def m3u_to_plex_ids(playlist): else: # Add-on paths not working, try direct kodi_id, kodi_type = kodidb.kodiid_from_filename( - playlist.kodi_path, db_type=playlist.type) + entry, db_type=playlist.type) if not kodi_id: continue with plexdb.Get_Plex_DB() as plex_db: plex_id = plex_db.getItem_byKodiId(kodi_id, kodi_type) if plex_id: - plex_ids.append(plex_id) + plex_ids.append(plex_id[0]) return plex_ids diff --git a/resources/lib/variables.py b/resources/lib/variables.py index e8fb9199..d08597e8 100644 --- a/resources/lib/variables.py +++ b/resources/lib/variables.py @@ -137,6 +137,10 @@ KODI_PLAYLIST_TYPE_FROM_PLEX = { PLEX_TYPE_AUDIO_PLAYLIST: KODI_TYPE_AUDIO_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