spotify-history: min. playback time for skipped tracks is now in seconds

This commit is contained in:
Philipp Wolfer 2024-01-14 22:22:00 +01:00
parent 01380bd730
commit 60bbbb9f15
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
2 changed files with 15 additions and 15 deletions

View file

@ -30,7 +30,7 @@ type StreamingHistory []HistoryItem
type ListenListOptions struct { type ListenListOptions struct {
IgnoreIncognito bool IgnoreIncognito bool
IgnoreSkipped bool IgnoreSkipped bool
SkippedMinDurationMs int skippedMinSeconds int
} }
type HistoryItem struct { type HistoryItem struct {
@ -72,7 +72,7 @@ func (h *StreamingHistory) AsListenList(opt ListenListOptions) models.ListensLis
if item.MasterMetadataTrackName == "" || if item.MasterMetadataTrackName == "" ||
(opt.IgnoreIncognito && item.IncognitoMode) || (opt.IgnoreIncognito && item.IncognitoMode) ||
(opt.IgnoreSkipped && item.Skipped) || (opt.IgnoreSkipped && item.Skipped) ||
(item.Skipped && item.MillisecondsPlayed < opt.SkippedMinDurationMs) { (item.Skipped && item.MillisecondsPlayed < opt.skippedMinSeconds*1000) {
continue continue
} }
listens = append(listens, item.AsListen()) listens = append(listens, item.AsListen())

View file

@ -36,7 +36,7 @@ type SpotifyHistoryBackend struct {
dirPath string dirPath string
ignoreIncognito bool ignoreIncognito bool
ignoreSkipped bool ignoreSkipped bool
skippedMinDurationMs int skippedMinSeconds int
} }
func (b *SpotifyHistoryBackend) Name() string { return "spotify-history" } func (b *SpotifyHistoryBackend) Name() string { return "spotify-history" }
@ -57,10 +57,10 @@ func (b *SpotifyHistoryBackend) Options() []models.BackendOption {
Type: models.Bool, Type: models.Bool,
Default: "false", Default: "false",
}, { }, {
Name: "ignore-min-duration-ms", Name: "ignore-min-duration-seconds",
Label: i18n.Tr("Minimum playback duration for skipped tracks (milliseconds)"), Label: i18n.Tr("Minimum playback duration for skipped tracks (seconds)"),
Type: models.Int, 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.dirPath = config.GetString("dir-path")
b.ignoreIncognito = config.GetBool("ignore-incognito", true) b.ignoreIncognito = config.GetBool("ignore-incognito", true)
b.ignoreSkipped = config.GetBool("ignore-skipped", false) 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 return b
} }
@ -95,7 +95,7 @@ func (b *SpotifyHistoryBackend) ExportListens(oldestTimestamp time.Time, results
listens := history.AsListenList(ListenListOptions{ listens := history.AsListenList(ListenListOptions{
IgnoreIncognito: b.ignoreIncognito, IgnoreIncognito: b.ignoreIncognito,
IgnoreSkipped: b.ignoreSkipped, IgnoreSkipped: b.ignoreSkipped,
SkippedMinDurationMs: b.skippedMinDurationMs, skippedMinSeconds: b.skippedMinSeconds,
}) })
sort.Sort(listens) sort.Sort(listens)
results <- models.ListensResult{Items: listens} results <- models.ListensResult{Items: listens}