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:
albumid = cursor.fetchone()[0]
except TypeError:
# Verify by name
query = ' '.join((
# Create the album
cursor.execute("select coalesce(max(idAlbum),0) from album")
albumid = cursor.fetchone()[0] + 1
query = (
'''
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID)
"SELECT idAlbum",
"FROM album",
"WHERE strAlbum = ?",
"COLLATE NOCASE"
))
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))
VALUES (?, ?, ?)
'''
)
cursor.execute(query, (albumid, name, musicbrainz))
return albumid