diff --git a/resources/lib/itemtypes/music.py b/resources/lib/itemtypes/music.py index 20dc516c..f54fac45 100644 --- a/resources/lib/itemtypes/music.py +++ b/resources/lib/itemtypes/music.py @@ -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): diff --git a/resources/lib/kodi_db/music.py b/resources/lib/kodi_db/music.py index 793b7a25..37f5c4a9 100644 --- a/resources/lib/kodi_db/music.py +++ b/resources/lib/kodi_db/music.py @@ -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(''' diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 62cd3b89..f5883668 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -327,6 +327,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