diff --git a/resources/lib/database.py b/resources/lib/database.py index ad7bfd91..360a1488 100644 --- a/resources/lib/database.py +++ b/resources/lib/database.py @@ -25,10 +25,6 @@ KODI = xbmc.getInfoLabel('System.BuildVersion')[:2] def video_database(): db_version = { - '13': 78, # Gotham - '14': 90, # Helix - '15': 93, # Isengard - '16': 99, # Jarvis '17': 107,# Krypton '18': 109 # Leia } @@ -38,12 +34,8 @@ def video_database(): def music_database(): db_version = { - '13': 46, # Gotham - '14': 48, # Helix - '15': 52, # Isengard - '16': 56, # Jarvis '17': 60, # Krypton - '18': 68 # Leia + '18': 70 # Leia } return xbmc.translatePath("special://database/MyMusic%s.db" % db_version.get(KODI, "")).decode('utf-8') diff --git a/resources/lib/objects/_kodi_music.py b/resources/lib/objects/_kodi_music.py index 831801b9..4007a935 100644 --- a/resources/lib/objects/_kodi_music.py +++ b/resources/lib/objects/_kodi_music.py @@ -131,6 +131,16 @@ class KodiMusic(KodiItems): )) self.cursor.execute(query, (args)) + def update_artist_18(self, *args): + query = ' '.join(( + + "UPDATE artist", + "SET strGenres = ?, strBiography = ?, strImage = ?, strFanart = ?,", + "lastScraped = ?", + "WHERE idArtist = ?" + )) + self.cursor.execute(query, (args)) + def link_artist(self, kodi_id, album_id, name): query = ( ''' @@ -168,23 +178,13 @@ class KodiMusic(KodiItems): def _add_album(self, name, musicbrainz): album_id = self.create_entry_album() - if self.kodi_version > 14: - query = ( - ''' - INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType) - VALUES (?, ?, ?, ?) - ''' - ) - self.cursor.execute(query, (album_id, name, musicbrainz, "album")) - else: - # TODO: Remove Helix code when Krypton is RC - query = ( - ''' - INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID) - VALUES (?, ?, ?) - ''' - ) - self.cursor.execute(query, (album_id, name, musicbrainz)) + query = ( + ''' + INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType) + VALUES (?, ?, ?, ?) + ''' + ) + self.cursor.execute(query, (album_id, name, musicbrainz, "album")) return album_id @@ -192,7 +192,17 @@ class KodiMusic(KodiItems): query = ' '.join(( "UPDATE album", - "SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,", + "SET strArtist = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,", + "iUserrating = ?, lastScraped = ?, strReleaseType = ?", + "WHERE idAlbum = ?" + )) + self.cursor.execute(query, (args)) + + def update_album_18(self, *args): + query = ' '.join(( + + "UPDATE album", + "SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,", "iUserrating = ?, lastScraped = ?, strReleaseType = ?", "WHERE idAlbum = ?" )) @@ -252,27 +262,6 @@ class KodiMusic(KodiItems): ) self.cursor.execute(query, (args)) - def add_single_15(self, *args): - query = ( - ''' - INSERT INTO album(idAlbum, strGenres, iYear, dateAdded, strReleaseType) - - VALUES (?, ?, ?, ?, ?) - ''' - ) - self.cursor.execute(query, (args)) - - def add_single_14(self, *args): - # TODO: Remove Helix code when Krypton is RC - query = ( - ''' - INSERT INTO album(idAlbum, strGenres, iYear, dateAdded) - - VALUES (?, ?, ?, ?) - ''' - ) - self.cursor.execute(query, (args)) - def add_song(self, *args): query = ( ''' diff --git a/resources/lib/objects/music.py b/resources/lib/objects/music.py index 9b8b3dc0..50d39c12 100644 --- a/resources/lib/objects/music.py +++ b/resources/lib/objects/music.py @@ -234,10 +234,10 @@ class Music(Items): emby_db.addReference(itemid, artistid, artisttype, "artist", checksum=checksum) # Process the artist - if self.kodi_version > 15: - self.kodi_db.update_artist_16(genres, bio, thumb, fanart, lastScraped, artistid) - else: + if self.kodi_version > 18: self.kodi_db.update_artist(genres, bio, thumb, fanart, lastScraped, dateadded, artistid) + else: + self.kodi_db.update_artist_18(genres, bio, thumb, fanart, lastScraped, artistid) # Update artwork artwork.add_artwork(artworks, artistid, "artist", kodicursor) @@ -303,8 +303,12 @@ class Music(Items): emby_db.addReference(itemid, albumid, "MusicAlbum", "album", checksum=checksum) # Process the album info - self.kodi_db.update_album(artistname, year, genre, bio, thumb, rating, lastScraped, - "album", albumid) + if self.kodi_version > 18: + self.kodi_db.update_album(artistname, year, genre, bio, thumb, rating, lastScraped, + "album", albumid) + else: + self.kodi_db.update_album_18(artistname, year, genre, bio, thumb, rating, lastScraped, + "album", albumid) # Assign main artists to album for artist in item['AlbumArtists']: @@ -340,7 +344,8 @@ class Music(Items): self.kodi_db.add_discography(artistid, name, year) # Add genres - self.kodi_db.add_genres(albumid, genres, "album") + if self.kodi_version > 18: + self.kodi_db.add_genres(albumid, genres, "album") # Update artwork artwork.add_artwork(artworks, albumid, "album", kodicursor)