OpenSubsonic: playbackReport extension (reportPlayback), integrated with now-playing/history
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user