mirror of
https://git.sr.ht/~phw/scotty
synced 2025-07-15 04:43:36 +02:00
Added Listen.Skipped attribute
This will help implementing similar functionality for other formats that make this distinction.
This commit is contained in:
parent
543b3ced27
commit
d162702d5d
3 changed files with 7 additions and 6 deletions
|
@ -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,8 +197,7 @@ 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,
|
||||
"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{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -106,6 +106,7 @@ type Listen struct {
|
|||
ListenedAt time.Time
|
||||
PlaybackDuration time.Duration
|
||||
UserName string
|
||||
Skipped bool
|
||||
}
|
||||
|
||||
type Love struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue