From 8ed3be521ba0251fda73dd1493a06077c546ebc1 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 17 Jun 2020 21:53:52 +0200 Subject: [PATCH] Add support for music database format v74 See the following commit for reference: https://github.com/xbmc/xbmc/commit/8fb8a640e076aa6fdd0c554892630d97bb067d07 Fixes #281 --- jellyfin_kodi/objects/kodi/music.py | 17 +++++++++++---- jellyfin_kodi/objects/kodi/queries_music.py | 23 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/jellyfin_kodi/objects/kodi/music.py b/jellyfin_kodi/objects/kodi/music.py index 831cbe43..dd7a78c9 100644 --- a/jellyfin_kodi/objects/kodi/music.py +++ b/jellyfin_kodi/objects/kodi/music.py @@ -160,8 +160,10 @@ class Music(Kodi): def update_album(self, *args): if self.version_id < 72: self.cursor.execute(QU.update_album, args) - else: + elif self.version_id < 74: self.cursor.execute(QU.update_album72, args) + else: + self.cursor.execute(QU.update_album74, args) def get_album_artist(self, album_id, artists): @@ -184,19 +186,26 @@ class Music(Kodi): self.cursor.execute(QU.update_album_artist72, args) def add_single(self, *args): - self.cursor.execute(QU.add_single, args) + if self.version_id < 74: + self.cursor.execute(QU.add_single, args) + else: + self.cursor.execute(QU.add_single74, args) def add_song(self, *args): if self.version_id < 72: self.cursor.execute(QU.add_song, args) - else: + elif self.version_id < 74: self.cursor.execute(QU.add_song72, args) + else: + self.cursor.execute(QU.add_song74, args) def update_song(self, *args): if self.version_id < 72: self.cursor.execute(QU.update_song, args) - else: + elif self.version_id < 74: self.cursor.execute(QU.update_song72, args) + else: + self.cursor.execute(QU.update_song74, args) def link_song_artist(self, *args): self.cursor.execute(QU.update_song_artist, args) diff --git a/jellyfin_kodi/objects/kodi/queries_music.py b/jellyfin_kodi/objects/kodi/queries_music.py index 836883bc..53d85ece 100644 --- a/jellyfin_kodi/objects/kodi/queries_music.py +++ b/jellyfin_kodi/objects/kodi/queries_music.py @@ -104,6 +104,10 @@ add_single = """ INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType) VALUES (?, ?, ?, ?) """ +add_single74 = """ +INSERT INTO album(idAlbum, strGenres, strReleaseDate, strReleaseType) +VALUES (?, ?, ?, ?) +""" add_single_obj = ["{AlbumId}", "{Genre}", "{Year}", "single"] add_song = """ INSERT INTO song(idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack, @@ -117,6 +121,12 @@ INSERT INTO song(idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle rating, comment, dateAdded) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """ +add_song74 = """ +INSERT INTO song(idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle, iTrack, + iDuration, strReleaseDate, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed, + rating, comment, dateAdded) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_song_obj = ["{SongId}", "{AlbumId}", "{PathId}", "{Artists}", "{Genre}", "{Title}", "{Index}", "{Runtime}", "{Year}", "{Filename}", "{UniqueId}", "{PlayCount}", "{DatePlayed}", "{Rating}", "{Comment}", "{DateAdded}"] @@ -171,6 +181,12 @@ SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage iUserrating = ?, lastScraped = ?, bScrapedMBID = 1, strReleaseType = ? WHERE idAlbum = ? """ +update_album74 = """ +UPDATE album +SET strArtistDisp = ?, strReleaseDate = ?, strGenres = ?, strReview = ?, strImage = ?, + iUserrating = ?, lastScraped = ?, bScrapedMBID = 1, strReleaseType = ? +WHERE idAlbum = ? +""" update_album_obj = ["{Artists}", "{Year}", "{Genre}", "{Bio}", "{Thumb}", "{Rating}", "{LastScraped}", "album", "{AlbumId}"] update_album_artist = """ UPDATE album @@ -196,6 +212,13 @@ SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack rating = ?, comment = ?, dateAdded = ? WHERE idSong = ? """ +update_song74 = """ +UPDATE song +SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack = ?, + iDuration = ?, strReleaseDate = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?, + rating = ?, comment = ?, dateAdded = ? +WHERE idSong = ? +""" update_song_obj = ["{AlbumId}", "{Artists}", "{Genre}", "{Title}", "{Index}", "{Runtime}", "{Year}", "{Filename}", "{PlayCount}", "{DatePlayed}", "{Rating}", "{Comment}", "{DateAdded}", "{SongId}"]