Fix recently added albums in Kodi 19

This commit is contained in:
Matt 2021-03-15 23:32:37 -04:00
parent 416ccf6ae1
commit 94b3a3e0a0
3 changed files with 17 additions and 2 deletions

View file

@ -158,8 +158,10 @@ class Music(Kodi):
album_id = album_id or self.create_entry_album() album_id = album_id or self.create_entry_album()
if self.version_id < 72: if self.version_id < 72:
self.cursor.execute(QU.add_album, (album_id,) + args) self.cursor.execute(QU.add_album, (album_id,) + args)
else: elif self.version_id < 82:
self.cursor.execute(QU.add_album72, (album_id,) + args) self.cursor.execute(QU.add_album72, (album_id,) + args)
else:
self.cursor.execute(QU.add_album82, (album_id,) + args)
return album_id return album_id
def update_album(self, *args): def update_album(self, *args):

View file

@ -54,6 +54,7 @@ FROM album
WHERE strMusicBrainzAlbumID = ? WHERE strMusicBrainzAlbumID = ?
""" """
get_album_obj = ["{AlbumId}", "{Title}", "{UniqueId}", "{Artists}", "album"] get_album_obj = ["{AlbumId}", "{Title}", "{UniqueId}", "{Artists}", "album"]
get_album_obj82 = ["{AlbumId}", "{Title}", "{UniqueId}", "{Artists}", "album", "{dateAdded}"]
get_album_by_name = """ get_album_by_name = """
SELECT idAlbum, strArtists SELECT idAlbum, strArtists
FROM album FROM album
@ -100,6 +101,10 @@ add_album72 = """
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID) INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID)
VALUES (?, ?, ?, ?, 1) VALUES (?, ?, ?, ?, 1)
""" """
add_album82 = """
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID, dateAdded)
VALUES (?, ?, ?, ?, 1, ?)
"""
add_single = """ add_single = """
INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType) INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType)
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)

View file

@ -153,6 +153,10 @@ class Music(KodiDb):
obj['Artists'] = " / ".join(obj['Artists'] or []) obj['Artists'] = " / ".join(obj['Artists'] or [])
obj['Artwork'] = API.get_all_artwork(self.objects.map(item, 'ArtworkMusic'), True) obj['Artwork'] = API.get_all_artwork(self.objects.map(item, 'ArtworkMusic'), True)
obj['Thumb'] = obj['Artwork']['Primary'] obj['Thumb'] = obj['Artwork']['Primary']
obj['dateAdded'] = item.get('DateCreated')
if obj['DateAdded']:
obj['DateAdded'] = Local(obj['DateAdded']).split('.')[0].replace('T', " ")
if obj['Thumb']: if obj['Thumb']:
obj['Thumb'] = "<thumb>%s</thumb>" % obj['Thumb'] obj['Thumb'] = "<thumb>%s</thumb>" % obj['Thumb']
@ -173,7 +177,11 @@ class Music(KodiDb):
''' Add object to kodi. ''' Add object to kodi.
''' '''
obj['AlbumId'] = self.get_album(*values(obj, QU.get_album_obj)) if self.version_id >= 82:
obj_values = values(obj, QU.get_album_obj82)
else:
obj_values = values(obj, QU.get_album_obj)
obj['AlbumId'] = self.get_album(*obj_values)
self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_album_obj)) self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_album_obj))
LOG.debug("ADD album [%s] %s: %s", obj['AlbumId'], obj['Title'], obj['Id']) LOG.debug("ADD album [%s] %s: %s", obj['AlbumId'], obj['Title'], obj['Id'])