mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-26 08:22:17 +03:00
Skip songs with less than 31 seconds, as per Last.fm specification
See https://www.last.fm/api/scrobbling#when-is-a-scrobble-a-scrobble
This commit is contained in:
parent
5040f6fd97
commit
0cbb0acad3
@ -186,6 +186,10 @@ func (l *lastfmAgent) Scrobble(ctx context.Context, userId string, scrobbles []s
|
|||||||
|
|
||||||
// TODO Implement batch scrobbling
|
// TODO Implement batch scrobbling
|
||||||
for _, s := range scrobbles {
|
for _, s := range scrobbles {
|
||||||
|
if s.Duration <= 30 {
|
||||||
|
log.Debug(ctx, "Skipping Last.fm scrobble for short song", "track", s.Title, "duration", s.Duration)
|
||||||
|
continue
|
||||||
|
}
|
||||||
err = l.client.Scrobble(ctx, sk, ScrobbleInfo{
|
err = l.client.Scrobble(ctx, sk, ScrobbleInfo{
|
||||||
artist: s.Artist,
|
artist: s.Artist,
|
||||||
track: s.Title,
|
track: s.Title,
|
||||||
|
@ -293,6 +293,17 @@ var _ = Describe("lastfmAgent", func() {
|
|||||||
Expect(sentParams.Get("mbid")).To(Equal(track.MbzTrackID))
|
Expect(sentParams.Get("mbid")).To(Equal(track.MbzTrackID))
|
||||||
Expect(sentParams.Get("timestamp")).To(Equal(strconv.FormatInt(ts.Unix(), 10)))
|
Expect(sentParams.Get("timestamp")).To(Equal(strconv.FormatInt(ts.Unix(), 10)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("skips songs with less than 31 seconds", func() {
|
||||||
|
track.Duration = 29
|
||||||
|
scrobbles := []scrobbler.Scrobble{{MediaFile: *track, TimeStamp: time.Now()}}
|
||||||
|
httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}
|
||||||
|
|
||||||
|
err := agent.Scrobble(ctx, "user-1", scrobbles)
|
||||||
|
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(httpClient.SavedRequest).To(BeNil())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user