OpenSubsonic: playbackReport extension (reportPlayback), integrated with now-playing/history

This commit is contained in:
2026-08-23 08:08:35 -05:00
parent d3074ab6fe
commit 4a5add80b6
4 changed files with 283 additions and 1 deletions
+10
View File
@@ -275,3 +275,13 @@ func TotalFilesSeenAcrossScans(db *sql.DB) (int64, error) {
err := db.QueryRow(`SELECT COALESCE(SUM(files_seen), 0) FROM scan_state WHERE status = 'scanning'`).Scan(&n)
return n, err
}
// RecordPlaybackReport stores one raw playback-timeline event (the
// OpenSubsonic reportPlayback extension), independent from the classic
// scrobbles/playback_history tables so a client's frequent timeline
// pings don't get conflated with actual "this was listened to" history.
func RecordPlaybackReport(db *sql.DB, userID, songID string, positionMs int, state, client string, playbackRate float64) error {
_, err := db.Exec(`INSERT INTO playback_reports (id, user_id, song_id, position_ms, state, playback_rate, client) VALUES (?, ?, ?, ?, ?, ?, ?)`,
idgen.New("pr"), userID, songID, positionMs, state, playbackRate, client)
return err
}