mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
* feat: search/merge items by id * feat: update track duration using musicbrainz * chore: changelog * fix: make username updates case insensitive * feat: add minutes listened to ui and fix image drop * chore: changelog * fix: embed db migrations (#37) * feat: Add support for ARM in publish workflow (#51) * chore: changelog * docs: search by id and custom theme support --------- Co-authored-by: potatoattack <lvl70nub@gmail.com> Co-authored-by: Benjamin Jonard <benjaminjonard@users.noreply.github.com>
25 lines
560 B
Go
25 lines
560 B
Go
package mbz
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type MusicBrainzTrack struct {
|
|
Title string `json:"title"`
|
|
LengthMs int `json:"length"`
|
|
}
|
|
|
|
const recordingFmtStr = "%s/ws/2/recording/%s"
|
|
|
|
// Returns the artist name at index 0, and all primary aliases after.
|
|
func (c *MusicBrainzClient) GetTrack(ctx context.Context, id uuid.UUID) (*MusicBrainzTrack, error) {
|
|
track := new(MusicBrainzTrack)
|
|
err := c.getEntity(ctx, recordingFmtStr, id, track)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("GetTrack: %w", err)
|
|
}
|
|
return track, nil
|
|
}
|