mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-18 11:09:29 +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 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())
|
||||||
|
|
|
@ -33,10 +33,10 @@ import (
|
||||||
const historyFileGlob = "Streaming_History_Audio_*.json"
|
const historyFileGlob = "Streaming_History_Audio_*.json"
|
||||||
|
|
||||||
type SpotifyHistoryBackend struct {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ func (b *SpotifyHistoryBackend) ExportListens(oldestTimestamp time.Time, results
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
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}
|
||||||
|
|
Loading…
Add table
Reference in a new issue