Music and parentid changes

Verify for artists on albums without musicbrainzid with same name
This commit is contained in:
angelblue05 2018-09-13 02:08:30 -05:00
parent eb83cfb6a4
commit dc7cfd54c3
4 changed files with 26 additions and 18 deletions

View file

@ -121,14 +121,18 @@ class Music(Kodi):
except TypeError: except TypeError:
return return
def get_album(self, album_id, name, musicbrainz, *args): def get_album(self, album_id, name, musicbrainz, artists=None, *args):
try:
if musicbrainz is not None: if musicbrainz is not None:
self.cursor.execute(QU.get_album, (musicbrainz,)) self.cursor.execute(QU.get_album, (musicbrainz,))
else: else:
self.cursor.execute(QU.get_album_by_name, (name,)) 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
try:
album_id = self.cursor.fetchone()[0] album_id = self.cursor.fetchone()[0]
except TypeError: except TypeError:
album_id = self.add_album(*(album_id, name, musicbrainz,) + args) album_id = self.add_album(*(album_id, name, musicbrainz,) + args)

View file

@ -47,9 +47,9 @@ get_album = """ SELECT idAlbum
FROM album FROM album
WHERE strMusicBrainzAlbumID = ? 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 FROM album
WHERE strAlbum = ? WHERE strAlbum = ?
""" """

View file

@ -167,9 +167,6 @@ class Music(KodiDb):
def album_add(self, obj): def album_add(self, obj):
''' Add object to kodi. ''' 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)) obj['AlbumId'] = self.get_album(*values(obj, QU.get_album_obj))
self.emby_db.add_reference(*values(obj, QUEM.add_reference_album_obj)) self.emby_db.add_reference(*values(obj, QUEM.add_reference_album_obj))

View file

@ -39,7 +39,8 @@
"Subtitles": "MediaSources/0/MediaStreams:?Type=Subtitle$Language", "Subtitles": "MediaSources/0/MediaStreams:?Type=Subtitle$Language",
"Audio": "MediaSources/0/MediaStreams:?Type=Audio", "Audio": "MediaSources/0/MediaStreams:?Type=Audio",
"Video": "MediaSources/0/MediaStreams:?Type=Video", "Video": "MediaSources/0/MediaStreams:?Type=Video",
"Container": "MediaSources/0/Container" "Container": "MediaSources/0/Container",
"EmbyParentId": "ParentId"
}, },
"MovieUserData": { "MovieUserData": {
"Id": "Id", "Id": "Id",
@ -74,7 +75,8 @@
"Studios": "Studios:?$Name", "Studios": "Studios:?$Name",
"Tags": "Tags", "Tags": "Tags",
"Favorite": "UserData/IsFavorite", "Favorite": "UserData/IsFavorite",
"RecursiveCount": "RecursiveItemCount" "RecursiveCount": "RecursiveItemCount",
"EmbyParentId": "ParentId"
}, },
"Season": { "Season": {
"Id": "Id", "Id": "Id",
@ -114,7 +116,8 @@
"Audio": "MediaSources/0/MediaStreams:?Type=Audio", "Audio": "MediaSources/0/MediaStreams:?Type=Audio",
"Video": "MediaSources/0/MediaStreams:?Type=Video", "Video": "MediaSources/0/MediaStreams:?Type=Video",
"Container": "MediaSources/0/Container", "Container": "MediaSources/0/Container",
"Location": "LocationType" "Location": "LocationType",
"EmbyParentId": "ParentId"
}, },
"EpisodeUserData": { "EpisodeUserData": {
"Id": "Id", "Id": "Id",
@ -154,7 +157,8 @@
"Tags": "Tags", "Tags": "Tags",
"Played": "UserData/Played", "Played": "UserData/Played",
"Favorite": "UserData/IsFavorite", "Favorite": "UserData/IsFavorite",
"Directors": "People:?Type=Director$Name" "Directors": "People:?Type=Director$Name",
"EmbyParentId": "ParentId"
}, },
"MusicVideoUserData": { "MusicVideoUserData": {
"Id": "Id", "Id": "Id",
@ -170,7 +174,8 @@
"Name": "Name", "Name": "Name",
"UniqueId": "ProviderIds/MusicBrainzArtist", "UniqueId": "ProviderIds/MusicBrainzArtist",
"Genres": "Genres", "Genres": "Genres",
"Bio": "Overview" "Bio": "Overview",
"EmbyParentId": "ParentId"
}, },
"Album": { "Album": {
"Id": "Id", "Id": "Id",
@ -181,7 +186,8 @@
"Bio": "Overview", "Bio": "Overview",
"AlbumArtists": "AlbumArtists", "AlbumArtists": "AlbumArtists",
"Artists": "AlbumArtists:?$Name", "Artists": "AlbumArtists:?$Name",
"ArtistItems": "ArtistItems" "ArtistItems": "ArtistItems",
"EmbyParentId": "ParentId"
}, },
"Song": { "Song": {
"Id": "Id", "Id": "Id",
@ -203,7 +209,8 @@
"AlbumArtists": "AlbumArtists", "AlbumArtists": "AlbumArtists",
"Album": "Album", "Album": "Album",
"SongAlbumId": "AlbumId", "SongAlbumId": "AlbumId",
"Container": "MediaSources/0/Container" "Container": "MediaSources/0/Container",
"EmbyParentId": "ParentId"
}, },
"SongUserData": { "SongUserData": {
"Id": "Id", "Id": "Id",