From 09b2c54675698c35f1435e2318e0da2a727d19e5 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 20 Dec 2020 14:54:07 +0100 Subject: [PATCH] Remove Music sync code for older Kodi version before Kodi Matrix --- resources/lib/itemtypes/music.py | 246 +++++++++---------------------- resources/lib/kodi_db/music.py | 153 ------------------- 2 files changed, 72 insertions(+), 327 deletions(-) diff --git a/resources/lib/itemtypes/music.py b/resources/lib/itemtypes/music.py index 89ccb9d9..2b99140d 100644 --- a/resources/lib/itemtypes/music.py +++ b/resources/lib/itemtypes/music.py @@ -126,8 +126,6 @@ class MusicMixin(object): # Check whether we have orphaned path entries if not self.kodidb.path_id_from_song(kodi_id): self.kodidb.remove_path(path_id) - if v.KODIVERSION < 18: - self.kodidb.remove_albuminfosong(kodi_id) self.kodidb.delete_artwork(kodi_id, v.KODI_TYPE_SONG) def remove_album(self, kodi_id): @@ -135,8 +133,6 @@ class MusicMixin(object): Remove an album ''' self.kodidb.delete_album_from_discography(kodi_id) - if v.KODIVERSION < 18: - self.kodidb.delete_album_from_album_genre(kodi_id) self.kodidb.remove_album(kodi_id) self.kodidb.delete_artwork(kodi_id, v.KODI_TYPE_ALBUM) @@ -290,72 +286,37 @@ class Album(MusicMixin, ItemBase): # UPDATE THE ALBUM ##### if update_item: LOG.info("UPDATE album plex_id: %s - Name: %s", plex_id, name) - if v.KODIVERSION >= 18: - self.kodidb.update_album(name, - musicBrainzId, - api.artist_name(), - genre, - api.year(), - compilation, - api.plot(), - thumb, - api.list_to_string(api.studios()), - api.userrating(), - timing.unix_date_to_kodi(self.last_sync), - 'album', - kodi_id) - else: - self.kodidb.update_album_17(name, - musicBrainzId, - api.artist_name(), - genre, - api.year(), - compilation, - api.plot(), - thumb, - api.list_to_string(api.studios()), - api.userrating(), - timing.unix_date_to_kodi(self.last_sync), - 'album', - kodi_id) + self.kodidb.update_album(name, + musicBrainzId, + api.artist_name(), + genre, + api.year(), + compilation, + api.plot(), + thumb, + api.list_to_string(api.studios()), + api.userrating(), + timing.unix_date_to_kodi(self.last_sync), + 'album', + kodi_id) # OR ADD THE ALBUM ##### else: LOG.info("ADD album plex_id: %s - Name: %s", plex_id, name) kodi_id = self.kodidb.new_album_id() - if v.KODIVERSION >= 18: - self.kodidb.add_album(kodi_id, - name, - musicBrainzId, - api.artist_name(), - genre, - api.year(), - compilation, - api.plot(), - thumb, - api.list_to_string(api.studios()), - api.userrating(), - timing.unix_date_to_kodi(self.last_sync), - 'album') - else: - self.kodidb.add_album_17(kodi_id, - name, - musicBrainzId, - api.artist_name(), - genre, - api.year(), - compilation, - api.plot(), - thumb, - api.list_to_string(api.studios()), - api.userrating(), - timing.unix_date_to_kodi(self.last_sync), - 'album') + self.kodidb.add_album(kodi_id, + name, + musicBrainzId, + api.artist_name(), + genre, + api.year(), + compilation, + api.plot(), + thumb, + api.list_to_string(api.studios()), + api.userrating(), + timing.unix_date_to_kodi(self.last_sync), + 'album') self.kodidb.add_albumartist(artist_id, kodi_id, api.artist_name()) - if v.KODIVERSION < 18: - self.kodidb.add_discography(artist_id, name, api.year()) - self.kodidb.add_music_genres(kodi_id, - api.genres(), - v.KODI_TYPE_ALBUM) if app.SYNC.artwork: self.kodidb.modify_artwork(artworks, kodi_id, @@ -436,34 +397,19 @@ class Song(MusicMixin, ItemBase): # No album found, create a single's album LOG.info('Creating singles album') parent_id = self.kodidb.new_album_id() - if v.KODIVERSION >= 18: - self.kodidb.add_album(kodi_id, - None, - None, - None, - genre, - api.year(), - None, - None, - None, - None, - None, - timing.unix_date_to_kodi(self.last_sync), - 'single') - else: - self.kodidb.add_album_17(kodi_id, - None, - None, - None, - genre, - api.year(), - None, - None, - None, - None, - None, - timing.unix_date_to_kodi(self.last_sync), - 'single') + self.kodidb.add_album(kodi_id, + None, + None, + None, + genre, + api.year(), + None, + None, + None, + None, + None, + timing.unix_date_to_kodi(self.last_sync), + 'single') else: album = self.plexdb.album(album_id) if not album: @@ -524,92 +470,44 @@ class Song(MusicMixin, ItemBase): LOG.info("UPDATE song plex_id: %s - %s", plex_id, title) # Use dummy strHash '123' for Kodi self.kodidb.update_path(path, kodi_pathid) - # Update the song entry - if v.KODIVERSION >= 18: - # Kodi Leia - self.kodidb.update_song(parent_id, - artists, - genre, - title, - track, - api.runtime(), - year, - filename, - api.viewcount(), - api.lastplayed(), - api.userrating(), - comment, - mood, - api.date_created(), - kodi_id) - else: - self.kodidb.update_song_17(parent_id, - artists, - genre, - title, - track, - api.runtime(), - year, - filename, - api.viewcount(), - api.lastplayed(), - api.userrating(), - comment, - mood, - api.date_created(), - kodi_id) + self.kodidb.update_song(parent_id, + artists, + genre, + title, + track, + api.runtime(), + year, + filename, + api.viewcount(), + api.lastplayed(), + api.userrating(), + comment, + mood, + api.date_created(), + kodi_id) # OR ADD THE SONG ##### else: LOG.info("ADD song plex_id: %s - %s", plex_id, title) # Add path kodi_pathid = self.kodidb.add_path(path) - # Create the song entry - if v.KODIVERSION >= 18: - # Kodi Leia - self.kodidb.add_song(kodi_id, - parent_id, - kodi_pathid, - artists, - genre, - title, - track, - api.runtime(), - year, - filename, - musicBrainzId, - api.viewcount(), - api.lastplayed(), - api.userrating(), - 0, - 0, - mood, - api.date_created()) - else: - self.kodidb.add_song_17(kodi_id, - parent_id, - kodi_pathid, - artists, - genre, - title, - track, - api.runtime(), - year, - filename, - musicBrainzId, - api.viewcount(), - api.lastplayed(), - api.userrating(), - 0, - 0, - mood, - api.date_created()) - if v.KODIVERSION < 18: - # Link song to album - self.kodidb.add_albuminfosong(kodi_id, - parent_id, - track, - title, - api.runtime()) + self.kodidb.add_song(kodi_id, + parent_id, + kodi_pathid, + artists, + genre, + title, + track, + api.runtime(), + year, + filename, + musicBrainzId, + api.viewcount(), + api.lastplayed(), + api.userrating(), + 0, + 0, + mood, + api.date_created()) # Link song to artists artist_name = api.grandparent_title() # Do the actual linking diff --git a/resources/lib/kodi_db/music.py b/resources/lib/kodi_db/music.py index a221a832..43bbcbbd 100644 --- a/resources/lib/kodi_db/music.py +++ b/resources/lib/kodi_db/music.py @@ -179,87 +179,6 @@ class KodiMusicDB(common.KodiDBBase): self.cursor.execute('SELECT COALESCE(MAX(idAlbum), 0) FROM album') return self.cursor.fetchone()[0] + 1 - @db.catch_operationalerrors - def add_album_17(self, *args): - """ - strReleaseType: 'album' or 'single' - """ - if app.SYNC.artwork: - self.cursor.execute(''' - INSERT INTO album( - idAlbum, - strAlbum, - strMusicBrainzAlbumID, - strArtists, - strGenres, - iYear, - bCompilation, - strReview, - strImage, - strLabel, - iUserrating, - lastScraped, - strReleaseType) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - ''', (args)) - else: - args = list(args) - del args[8] - self.cursor.execute(''' - INSERT INTO album( - idAlbum, - strAlbum, - strMusicBrainzAlbumID, - strArtists, - strGenres, - iYear, - bCompilation, - strReview, - strLabel, - iUserrating, - lastScraped, - strReleaseType) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - ''', (args)) - - @db.catch_operationalerrors - def update_album_17(self, *args): - if app.SYNC.artwork: - self.cursor.execute(''' - UPDATE album - SET strAlbum = ?, - strMusicBrainzAlbumID = ?, - strArtists = ?, - strGenres = ?, - iYear = ?, - bCompilation = ?, - strReview = ?, - strImage = ?, - strLabel = ?, - iUserrating = ?, - lastScraped = ?, - strReleaseType = ? - WHERE idAlbum = ? - ''', (args)) - else: - args = list(args) - del args[7] - self.cursor.execute(''' - UPDATE album - SET strAlbum = ?, - strMusicBrainzAlbumID = ?, - strArtists = ?, - strGenres = ?, - iYear = ?, - bCompilation = ?, - strReview = ?, - strLabel = ?, - iUserrating = ?, - lastScraped = ?, - strReleaseType = ? - WHERE idAlbum = ? - ''', (args)) - @db.catch_operationalerrors def add_album(self, *args): """ @@ -351,16 +270,6 @@ class KodiMusicDB(common.KodiDBBase): VALUES (?, ?, ?) ''', (artist_id, kodi_id, artistname)) - @db.catch_operationalerrors - def add_discography(self, artist_id, albumname, year): - self.cursor.execute(''' - INSERT OR REPLACE INTO discography( - idArtist, - strAlbum, - strYear) - VALUES (?, ?, ?) - ''', (artist_id, albumname, year)) - @db.catch_operationalerrors def add_music_genres(self, kodiid, genres, mediatype): """ @@ -437,31 +346,6 @@ class KodiMusicDB(common.KodiDBBase): VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ''', (args)) - @db.catch_operationalerrors - def add_song_17(self, *args): - self.cursor.execute(''' - INSERT INTO song( - idSong, - idAlbum, - idPath, - strArtists, - strGenres, - strTitle, - iTrack, - iDuration, - iYear, - strFileName, - strMusicBrainzTrackID, - iTimesPlayed, - lastplayed, - rating, - iStartOffset, - iEndOffset, - mood, - dateAdded) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - ''', (args)) - @db.catch_operationalerrors def update_song(self, *args): self.cursor.execute(''' @@ -492,27 +376,6 @@ class KodiMusicDB(common.KodiDBBase): WHERE idSong = ? ''', (args)) - @db.catch_operationalerrors - def update_song_17(self, *args): - self.cursor.execute(''' - UPDATE song - SET idAlbum = ?, - strArtists = ?, - strGenres = ?, - strTitle = ?, - iTrack = ?, - iDuration = ?, - iYear = ?, - strFilename = ?, - iTimesPlayed = ?, - lastplayed = ?, - rating = ?, - comment = ?, - mood = ?, - dateAdded = ? - WHERE idSong = ? - ''', (args)) - def path_id_from_song(self, kodi_id): self.cursor.execute('SELECT idPath FROM song WHERE idSong = ? LIMIT 1', (kodi_id, )) @@ -596,22 +459,6 @@ class KodiMusicDB(common.KodiDBBase): VALUES (?, ?, ?, ?, ?) ''', (artist_id, song_id, 1, 0, artist_name)) - @db.catch_operationalerrors - def add_albuminfosong(self, song_id, album_id, track_no, track_title, - runtime): - """ - Kodi 17 only - """ - self.cursor.execute(''' - INSERT OR REPLACE INTO albuminfosong( - idAlbumInfoSong, - idAlbumInfo, - iTrack, - strTitle, - iDuration) - VALUES (?, ?, ?, ?, ?) - ''', (song_id, album_id, track_no, track_title, runtime)) - @db.catch_operationalerrors def update_userrating(self, kodi_id, kodi_type, userrating): """