mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-01 14:17:06 +02:00
JSPF: Include full LB additional info in metadata
This commit is contained in:
parent
36cc41d05d
commit
68b2e649f0
3 changed files with 100 additions and 14 deletions
|
@ -51,6 +51,48 @@ func (t Track) ArtistName() string {
|
|||
return strings.Join(t.ArtistNames, ", ")
|
||||
}
|
||||
|
||||
// Updates AdditionalInfo to have standard fields as defined by ListenBrainz
|
||||
func (t *Track) FillAdditionalInfo() {
|
||||
if t.AdditionalInfo == nil {
|
||||
t.AdditionalInfo = make(AdditionalInfo, 5)
|
||||
}
|
||||
if t.RecordingMbid != "" {
|
||||
t.AdditionalInfo["recording_mbid"] = t.RecordingMbid
|
||||
}
|
||||
if t.ReleaseGroupMbid != "" {
|
||||
t.AdditionalInfo["release_group_mbid"] = t.ReleaseGroupMbid
|
||||
}
|
||||
if t.ReleaseMbid != "" {
|
||||
t.AdditionalInfo["release_mbid"] = t.ReleaseMbid
|
||||
}
|
||||
if len(t.ArtistMbids) > 0 {
|
||||
t.AdditionalInfo["artist_mbids"] = t.ArtistMbids
|
||||
}
|
||||
if len(t.WorkMbids) > 0 {
|
||||
t.AdditionalInfo["work_mbids"] = t.WorkMbids
|
||||
}
|
||||
if t.ISRC != "" {
|
||||
t.AdditionalInfo["isrc"] = t.ISRC
|
||||
}
|
||||
if t.TrackNumber != 0 {
|
||||
t.AdditionalInfo["tracknumber"] = t.TrackNumber
|
||||
}
|
||||
if t.DiscNumber != 0 {
|
||||
t.AdditionalInfo["discnumber"] = t.DiscNumber
|
||||
}
|
||||
if t.Duration != 0 {
|
||||
rounded := t.Duration.Round(time.Second)
|
||||
if t.Duration == rounded {
|
||||
t.AdditionalInfo["duration"] = int64(t.Duration.Seconds())
|
||||
} else {
|
||||
t.AdditionalInfo["duration_ms"] = t.Duration.Milliseconds()
|
||||
}
|
||||
}
|
||||
if len(t.Tags) > 0 {
|
||||
t.AdditionalInfo["tags"] = t.Tags
|
||||
}
|
||||
}
|
||||
|
||||
type Listen struct {
|
||||
Track
|
||||
ListenedAt time.Time
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue