Fix music items getting deleted on startup

This commit is contained in:
croneter 2019-02-03 17:20:36 +01:00
parent 1dbeb95e24
commit 8f8ccd1daf
3 changed files with 17 additions and 6 deletions

View file

@ -52,12 +52,9 @@ class MusicMixin(object):
db_item['kodi_type'],
userdata['UserRating'])
if plex_type == v.PLEX_TYPE_SONG:
self.kodidb.set_resume(db_item['kodi_fileid'],
userdata['Resume'],
userdata['Runtime'],
userdata['PlayCount'],
userdata['LastPlayedDate'],
plex_type)
self.kodidb.set_playcount(userdata['PlayCount'],
userdata['LastPlayedDate'],
db_item['kodi_id'],)
return True
def remove(self, plex_id, plex_type=None):

View file

@ -459,6 +459,15 @@ class KodiMusicDB(common.KodiDBBase):
WHERE idSong = ?
''', (args))
@common.catch_operationalerrors
def set_playcount(self, *args):
self.cursor.execute('''
UPDATE song
SET iTimesPlayed = ?,
lastplayed = ?
WHERE idSong = ?
''', (args))
@common.catch_operationalerrors
def update_song_17(self, *args):
self.cursor.execute('''

View file

@ -323,6 +323,11 @@ class FullSync(common.fullsync_mixin):
if self.successful:
# Set timestamp for next sync - neglecting playstates!
utils.settings('lastfullsync', value=str(int(self.current_sync)))
# In order to not delete all your songs again
if app.SYNC.enable_music:
kinds.extend([
(v.PLEX_TYPE_SONG, v.PLEX_TYPE_ARTIST, itemtypes.Song, True),
])
# SYNC PLAYSTATE of ALL items (otherwise we won't pick up on items that
# were set to unwatched). Also mark all items on the PMS to be able
# to delete the ones still in Kodi