From 6329ead9d3c40eab74fa727c2cce0a415af3c6a2 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sun, 11 Mar 2018 21:50:52 -0500 Subject: [PATCH] Fix music Fix multiple albums being created due to missing musicbrainzid. --- resources/lib/objects/_kodi_music.py | 26 ++++++++++++++++++-------- resources/lib/objects/music.py | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/resources/lib/objects/_kodi_music.py b/resources/lib/objects/_kodi_music.py index 5c7263a8..286cc121 100644 --- a/resources/lib/objects/_kodi_music.py +++ b/resources/lib/objects/_kodi_music.py @@ -126,7 +126,7 @@ class KodiMusic(KodiItems): "UPDATE artist", "SET strGenres = ?, strBiography = ?, strImage = ?, strFanart = ?,", - "lastScraped = ?, dateAdded = ?", + "lastScraped = ?", "WHERE idArtist = ?" )) self.cursor.execute(query, (args)) @@ -159,15 +159,25 @@ class KodiMusic(KodiItems): ) self.cursor.execute(query, (kodi_id, album, year)) - def get_album(self, name, musicbrainz): + def get_album(self, name, musicbrainz=None): - query = ' '.join(( + if musicbrainz is not None: + query = ' '.join(( + + "SELECT idAlbum", + "FROM album", + "WHERE strMusicBrainzAlbumID = ?" + )) + self.cursor.execute(query, (musicbrainz,)) + else: + query = ' '.join(( + + "SELECT idAlbum", + "FROM album", + "WHERE strMusicBrainzAlbumID = ?" + )) + self.cursor.execute(query, (name,)) - "SELECT idAlbum", - "FROM album", - "WHERE strMusicBrainzAlbumID = ?" - )) - self.cursor.execute(query, (musicbrainz,)) try: album_id = self.cursor.fetchone()[0] except TypeError: diff --git a/resources/lib/objects/music.py b/resources/lib/objects/music.py index 76485ade..32ab63e4 100644 --- a/resources/lib/objects/music.py +++ b/resources/lib/objects/music.py @@ -235,7 +235,7 @@ class Music(Items): # Process the artist if self.kodi_version < 18: - self.kodi_db.update_artist(genres, bio, thumb, fanart, lastScraped, dateadded, artistid) + self.kodi_db.update_artist(genres, bio, thumb, fanart, lastScraped, artistid) else: self.kodi_db.update_artist_18(genres, bio, thumb, fanart, lastScraped, artistid)