mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-10 23:49:28 +02:00
spotify-history: min. playback time for skipped tracks is now in seconds
This commit is contained in:
parent
01380bd730
commit
60bbbb9f15
2 changed files with 15 additions and 15 deletions
|
@ -28,9 +28,9 @@ import (
|
|||
type StreamingHistory []HistoryItem
|
||||
|
||||
type ListenListOptions struct {
|
||||
IgnoreIncognito bool
|
||||
IgnoreSkipped bool
|
||||
SkippedMinDurationMs int
|
||||
IgnoreIncognito bool
|
||||
IgnoreSkipped bool
|
||||
skippedMinSeconds int
|
||||
}
|
||||
|
||||
type HistoryItem struct {
|
||||
|
@ -72,7 +72,7 @@ func (h *StreamingHistory) AsListenList(opt ListenListOptions) models.ListensLis
|
|||
if item.MasterMetadataTrackName == "" ||
|
||||
(opt.IgnoreIncognito && item.IncognitoMode) ||
|
||||
(opt.IgnoreSkipped && item.Skipped) ||
|
||||
(item.Skipped && item.MillisecondsPlayed < opt.SkippedMinDurationMs) {
|
||||
(item.Skipped && item.MillisecondsPlayed < opt.skippedMinSeconds*1000) {
|
||||
continue
|
||||
}
|
||||
listens = append(listens, item.AsListen())
|
||||
|
|
|
@ -33,10 +33,10 @@ import (
|
|||
const historyFileGlob = "Streaming_History_Audio_*.json"
|
||||
|
||||
type SpotifyHistoryBackend struct {
|
||||
dirPath string
|
||||
ignoreIncognito bool
|
||||
ignoreSkipped bool
|
||||
skippedMinDurationMs int
|
||||
dirPath string
|
||||
ignoreIncognito bool
|
||||
ignoreSkipped bool
|
||||
skippedMinSeconds int
|
||||
}
|
||||
|
||||
func (b *SpotifyHistoryBackend) Name() string { return "spotify-history" }
|
||||
|
@ -57,10 +57,10 @@ func (b *SpotifyHistoryBackend) Options() []models.BackendOption {
|
|||
Type: models.Bool,
|
||||
Default: "false",
|
||||
}, {
|
||||
Name: "ignore-min-duration-ms",
|
||||
Label: i18n.Tr("Minimum playback duration for skipped tracks (milliseconds)"),
|
||||
Name: "ignore-min-duration-seconds",
|
||||
Label: i18n.Tr("Minimum playback duration for skipped tracks (seconds)"),
|
||||
Type: models.Int,
|
||||
Default: "30000",
|
||||
Default: "30",
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ func (b *SpotifyHistoryBackend) FromConfig(config *config.ServiceConfig) models.
|
|||
b.dirPath = config.GetString("dir-path")
|
||||
b.ignoreIncognito = config.GetBool("ignore-incognito", true)
|
||||
b.ignoreSkipped = config.GetBool("ignore-skipped", false)
|
||||
b.skippedMinDurationMs = config.GetInt("ignore-min-duration-ms", 30000)
|
||||
b.skippedMinSeconds = config.GetInt("ignore-min-duration-seconds", 30)
|
||||
return b
|
||||
}
|
||||
|
||||
|
@ -93,9 +93,9 @@ func (b *SpotifyHistoryBackend) ExportListens(oldestTimestamp time.Time, results
|
|||
return
|
||||
}
|
||||
listens := history.AsListenList(ListenListOptions{
|
||||
IgnoreIncognito: b.ignoreIncognito,
|
||||
IgnoreSkipped: b.ignoreSkipped,
|
||||
SkippedMinDurationMs: b.skippedMinDurationMs,
|
||||
IgnoreIncognito: b.ignoreIncognito,
|
||||
IgnoreSkipped: b.ignoreSkipped,
|
||||
skippedMinSeconds: b.skippedMinSeconds,
|
||||
})
|
||||
sort.Sort(listens)
|
||||
results <- models.ListensResult{Items: listens}
|
||||
|
|
Loading…
Add table
Reference in a new issue