From dc7cfd54c35325921002472ad1cbd9a793edef44 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 13 Sep 2018 02:08:30 -0500 Subject: [PATCH] Music and parentid changes Verify for artists on albums without musicbrainzid with same name --- resources/lib/objects/kodi/music.py | 16 ++++++++++------ resources/lib/objects/kodi/queries_music.py | 4 ++-- resources/lib/objects/music.py | 3 --- resources/lib/objects/obj_map.json | 21 ++++++++++++++------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/resources/lib/objects/kodi/music.py b/resources/lib/objects/kodi/music.py index 35514b72..98bf56e2 100644 --- a/resources/lib/objects/kodi/music.py +++ b/resources/lib/objects/kodi/music.py @@ -121,14 +121,18 @@ class Music(Kodi): except TypeError: return - def get_album(self, album_id, name, musicbrainz, *args): - - if musicbrainz is not None: - self.cursor.execute(QU.get_album, (musicbrainz,)) - else: - self.cursor.execute(QU.get_album_by_name, (name,)) + def get_album(self, album_id, name, musicbrainz, artists=None, *args): try: + if musicbrainz is not None: + self.cursor.execute(QU.get_album, (musicbrainz,)) + else: + self.cursor.execute(QU.get_album_by_name, (name,)) + album = self.cursor.fetchone() + + if album[1] and album[1] not in artists.split(' / '): + raise TypeError + album_id = self.cursor.fetchone()[0] except TypeError: album_id = self.add_album(*(album_id, name, musicbrainz,) + args) diff --git a/resources/lib/objects/kodi/queries_music.py b/resources/lib/objects/kodi/queries_music.py index eca4baa1..da481f36 100644 --- a/resources/lib/objects/kodi/queries_music.py +++ b/resources/lib/objects/kodi/queries_music.py @@ -47,9 +47,9 @@ get_album = """ SELECT idAlbum FROM album WHERE strMusicBrainzAlbumID = ? """ -get_album_obj = [ "{AlbumId}","{Title}","{UniqueId}","album" +get_album_obj = [ "{AlbumId}","{Title}","{UniqueId}","{Artists}","album" ] -get_album_by_name = """ SELECT idAlbum +get_album_by_name = """ SELECT idAlbum, strArtists FROM album WHERE strAlbum = ? """ diff --git a/resources/lib/objects/music.py b/resources/lib/objects/music.py index 041ffa0e..1ec67fee 100644 --- a/resources/lib/objects/music.py +++ b/resources/lib/objects/music.py @@ -167,9 +167,6 @@ class Music(KodiDb): def album_add(self, obj): ''' Add object to kodi. - - safety checks: It looks like Emby supports the same artist multiple times. - Kodi doesn't allow that. In case that happens we just merge the artist entries. ''' obj['AlbumId'] = self.get_album(*values(obj, QU.get_album_obj)) self.emby_db.add_reference(*values(obj, QUEM.add_reference_album_obj)) diff --git a/resources/lib/objects/obj_map.json b/resources/lib/objects/obj_map.json index a2733906..416d71e0 100644 --- a/resources/lib/objects/obj_map.json +++ b/resources/lib/objects/obj_map.json @@ -39,7 +39,8 @@ "Subtitles": "MediaSources/0/MediaStreams:?Type=Subtitle$Language", "Audio": "MediaSources/0/MediaStreams:?Type=Audio", "Video": "MediaSources/0/MediaStreams:?Type=Video", - "Container": "MediaSources/0/Container" + "Container": "MediaSources/0/Container", + "EmbyParentId": "ParentId" }, "MovieUserData": { "Id": "Id", @@ -74,7 +75,8 @@ "Studios": "Studios:?$Name", "Tags": "Tags", "Favorite": "UserData/IsFavorite", - "RecursiveCount": "RecursiveItemCount" + "RecursiveCount": "RecursiveItemCount", + "EmbyParentId": "ParentId" }, "Season": { "Id": "Id", @@ -114,7 +116,8 @@ "Audio": "MediaSources/0/MediaStreams:?Type=Audio", "Video": "MediaSources/0/MediaStreams:?Type=Video", "Container": "MediaSources/0/Container", - "Location": "LocationType" + "Location": "LocationType", + "EmbyParentId": "ParentId" }, "EpisodeUserData": { "Id": "Id", @@ -154,7 +157,8 @@ "Tags": "Tags", "Played": "UserData/Played", "Favorite": "UserData/IsFavorite", - "Directors": "People:?Type=Director$Name" + "Directors": "People:?Type=Director$Name", + "EmbyParentId": "ParentId" }, "MusicVideoUserData": { "Id": "Id", @@ -170,7 +174,8 @@ "Name": "Name", "UniqueId": "ProviderIds/MusicBrainzArtist", "Genres": "Genres", - "Bio": "Overview" + "Bio": "Overview", + "EmbyParentId": "ParentId" }, "Album": { "Id": "Id", @@ -181,7 +186,8 @@ "Bio": "Overview", "AlbumArtists": "AlbumArtists", "Artists": "AlbumArtists:?$Name", - "ArtistItems": "ArtistItems" + "ArtistItems": "ArtistItems", + "EmbyParentId": "ParentId" }, "Song": { "Id": "Id", @@ -203,7 +209,8 @@ "AlbumArtists": "AlbumArtists", "Album": "Album", "SongAlbumId": "AlbumId", - "Container": "MediaSources/0/Container" + "Container": "MediaSources/0/Container", + "EmbyParentId": "ParentId" }, "SongUserData": { "Id": "Id",