Added Listen.Skipped attribute

This will help implementing similar functionality for other formats
that make this distinction.
This commit is contained in:
Philipp Wolfer 2025-07-14 15:13:38 +02:00
parent 543b3ced27
commit d162702d5d
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
3 changed files with 7 additions and 6 deletions

View file

@ -188,6 +188,7 @@ func (b *ScrobblerLogBackend) ImportListens(ctx context.Context, export models.L
func recordToListen(record scrobblerlog.Record, client string) models.Listen {
return models.Listen{
ListenedAt: record.Timestamp,
Skipped: record.Rating == scrobblerlog.RatingSkipped,
Track: models.Track{
ArtistNames: []string{record.ArtistName},
ReleaseName: record.AlbumName,
@ -196,7 +197,6 @@ func recordToListen(record scrobblerlog.Record, client string) models.Listen {
Duration: record.Duration,
RecordingMBID: record.MusicBrainzRecordingID,
AdditionalInfo: models.AdditionalInfo{
"rockbox_rating": record.Rating,
"media_player": client,
},
},
@ -205,11 +205,10 @@ func recordToListen(record scrobblerlog.Record, client string) models.Listen {
func listenToRecord(listen models.Listen) scrobblerlog.Record {
var rating scrobblerlog.Rating
rockboxRating, ok := listen.AdditionalInfo["rockbox_rating"].(string)
if !ok || rockboxRating == "" {
rating = scrobblerlog.RatingListened
if listen.Skipped {
rating = scrobblerlog.RatingSkipped
} else {
rating = scrobblerlog.Rating(rating)
rating = scrobblerlog.RatingListened
}
return scrobblerlog.Record{

View file

@ -91,6 +91,7 @@ func (i HistoryItem) AsListen() models.Listen {
ListenedAt: i.Timestamp,
PlaybackDuration: time.Duration(i.MillisecondsPlayed) * time.Millisecond,
UserName: i.UserName,
Skipped: i.Skipped,
}
if trackURL, err := formatSpotifyUri(i.SpotifyTrackUri); err != nil {
listen.AdditionalInfo["spotify_id"] = trackURL

View file

@ -106,6 +106,7 @@ type Listen struct {
ListenedAt time.Time
PlaybackDuration time.Duration
UserName string
Skipped bool
}
type Love struct {