Fix albums with same name

This commit is contained in:
angelblue05 2016-01-01 23:24:28 -06:00
parent 227bb3eb42
commit 77de12bec8

View file

@ -1050,29 +1050,17 @@ class Kodidb_Functions():
try: try:
albumid = cursor.fetchone()[0] albumid = cursor.fetchone()[0]
except TypeError: except TypeError:
# Verify by name # Create the album
query = ' '.join(( cursor.execute("select coalesce(max(idAlbum),0) from album")
albumid = cursor.fetchone()[0] + 1
query = (
'''
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID)
"SELECT idAlbum", VALUES (?, ?, ?)
"FROM album", '''
"WHERE strAlbum = ?", )
"COLLATE NOCASE" cursor.execute(query, (albumid, name, musicbrainz))
))
cursor.execute(query, (name,))
try:
albumid = cursor.fetchone()[0]
except TypeError:
# Create the album
cursor.execute("select coalesce(max(idAlbum),0) from album")
albumid = cursor.fetchone()[0] + 1
query = (
'''
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID)
VALUES (?, ?, ?)
'''
)
cursor.execute(query, (albumid, name, musicbrainz))
return albumid return albumid