Music: Enter Zero, not Null in DB

This commit is contained in:
tomkat83 2016-04-08 14:48:47 +02:00
parent 9528577aab
commit a3d964dff4

View file

@ -2041,6 +2041,9 @@ class Music(Items):
dateadded = API.getDateCreated() dateadded = API.getDateCreated()
userdata = API.getUserData() userdata = API.getUserData()
playcount = userdata['PlayCount'] playcount = userdata['PlayCount']
if playcount is None:
# This is different to Video DB!
playcount = 0
dateplayed = userdata['LastPlayedDate'] dateplayed = userdata['LastPlayedDate']
# item details # item details
@ -2058,7 +2061,7 @@ class Music(Items):
track = disc*2**16 + tracknumber track = disc*2**16 + tracknumber
year = API.getYear() year = API.getYear()
resume, duration = API.getRuntime() resume, duration = API.getRuntime()
rating = userdata['UserRating'] rating = int(userdata['UserRating'])
#if enabled, try to get the rating from file and/or emby #if enabled, try to get the rating from file and/or emby
# if not self.directstream: # if not self.directstream:
@ -2205,15 +2208,15 @@ class Music(Items):
INSERT INTO song( INSERT INTO song(
idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack, idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack,
iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed, iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating) rating, iStartOffset, iEndOffset)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
) )
kodicursor.execute( kodicursor.execute(
query, (songid, albumid, pathid, artists, genre, title, track, query, (songid, albumid, pathid, artists, genre, title, track,
duration, year, filename, musicBrainzId, playcount, duration, year, filename, musicBrainzId, playcount,
dateplayed, rating)) dateplayed, rating, 0, 0))
# Create the reference in emby table # Create the reference in emby table
emby_db.addReference( emby_db.addReference(