Fix newly added album/songs
Since we process a dictionary, we can't really control the order it's being processed in. Audio is being added before the album, so added an album verification at song level.
This commit is contained in:
parent
c37a9efdf3
commit
363b458514
1 changed files with 39 additions and 31 deletions
|
@ -18,7 +18,8 @@ import utils
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
import kodidb_functions as kodidb
|
import kodidb_functions as kodidb
|
||||||
import read_embyserver as embyserver
|
import read_embyserver as embyserver
|
||||||
import musicutils as musicutils
|
import musicutils
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -2040,39 +2041,46 @@ class Music(Items):
|
||||||
self.logMsg("Song itemid: %s has no albumId." % itemid, 1)
|
self.logMsg("Song itemid: %s has no albumId." % itemid, 1)
|
||||||
return
|
return
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# No album found, create a single's album
|
# No album found. Let's create it
|
||||||
kodicursor.execute("select coalesce(max(idAlbum),0) from album")
|
emby_albumId = item['AlbumId']
|
||||||
albumid = kodicursor.fetchone()[0] + 1
|
album = emby.getItem(emby_albumId)
|
||||||
if kodiversion in (16, 17):
|
emby_dbalbum = emby_db.getItem_byId(emby_albumId)
|
||||||
# Kodi Jarvis, Krypton
|
try:
|
||||||
query = (
|
albumid = emby_dbalbum[0]
|
||||||
'''
|
except TypeError:
|
||||||
INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType)
|
# No album found, create a single's album
|
||||||
|
kodicursor.execute("select coalesce(max(idAlbum),0) from album")
|
||||||
|
albumid = kodicursor.fetchone()[0] + 1
|
||||||
|
if kodiversion == 16:
|
||||||
|
# Kodi Jarvis
|
||||||
|
query = (
|
||||||
|
'''
|
||||||
|
INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType)
|
||||||
|
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
kodicursor.execute(query, (albumid, genre, year, "single"))
|
kodicursor.execute(query, (albumid, genre, year, "single"))
|
||||||
elif kodiversion == 15:
|
elif kodiversion == 15:
|
||||||
# Kodi Isengard
|
# Kodi Isengard
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
INSERT INTO album(idAlbum, strGenres, iYear, dateAdded, strReleaseType)
|
INSERT INTO album(idAlbum, strGenres, iYear, dateAdded, strReleaseType)
|
||||||
|
|
||||||
VALUES (?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
kodicursor.execute(query, (albumid, genre, year, dateadded, "single"))
|
kodicursor.execute(query, (albumid, genre, year, dateadded, "single"))
|
||||||
else:
|
else:
|
||||||
# Kodi Helix
|
# Kodi Helix
|
||||||
query = (
|
query = (
|
||||||
'''
|
'''
|
||||||
INSERT INTO album(idAlbum, strGenres, iYear, dateAdded)
|
INSERT INTO album(idAlbum, strGenres, iYear, dateAdded)
|
||||||
|
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
kodicursor.execute(query, (albumid, genre, year, dateadded))
|
kodicursor.execute(query, (albumid, genre, year, dateadded))
|
||||||
|
|
||||||
# Create the song entry
|
# Create the song entry
|
||||||
kodicursor.execute("select coalesce(max(idSong),0) from song")
|
kodicursor.execute("select coalesce(max(idSong),0) from song")
|
||||||
|
|
Loading…
Reference in a new issue