✨ Get tags from mb
This commit is contained in:
parent
739bed214c
commit
5881f3d538
5 changed files with 190 additions and 32 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
type Recording struct {
|
||||
Id uuid.UUID
|
||||
AcousticId uuid.UUID
|
||||
Isrcs []string
|
||||
FirstReleaseDate string `json:"first-release-date"`
|
||||
Length int
|
||||
|
|
@ -66,21 +67,57 @@ type Genre struct {
|
|||
}
|
||||
|
||||
type Release struct {
|
||||
Id uuid.UUID
|
||||
Country string
|
||||
Date string
|
||||
Media []Media
|
||||
Status string
|
||||
StatusId uuid.UUID `json:"status-id"`
|
||||
ArtistCredit []ArtistCredit `json:"artist-credit"`
|
||||
Title string
|
||||
Genres []Genre
|
||||
Id uuid.UUID
|
||||
Asin string
|
||||
Barcode string
|
||||
Country string
|
||||
Date string
|
||||
Disambiguation string
|
||||
Media []Media
|
||||
Packaging string
|
||||
PackagingId uuid.UUID `json:"packaging-id"`
|
||||
Quality string
|
||||
Status string
|
||||
StatusId uuid.UUID `json:"status-id"`
|
||||
ArtistCredit []ArtistCredit `json:"artist-credit"`
|
||||
Title string
|
||||
Genres []Genre
|
||||
ReleaseGroup ReleaseGroup `json:"release-group"`
|
||||
LabelInfo []LabelInfo `json:"label-info"`
|
||||
// ReleaseEvents []ReleaseEvent `json:"release-events"`
|
||||
}
|
||||
|
||||
type LabelInfo struct {
|
||||
CatalogNumber string `json:"catalog-number"`
|
||||
Label Label
|
||||
}
|
||||
|
||||
type Label struct {
|
||||
Id uuid.UUID
|
||||
Name string
|
||||
SortName string `json:"sort-name"`
|
||||
Disambiguation string
|
||||
TypeId string `json:"type-id"`
|
||||
Type string
|
||||
LabelCode int `json:"label-code"`
|
||||
}
|
||||
|
||||
type ReleaseGroup struct {
|
||||
Id uuid.UUID
|
||||
Title string
|
||||
ArtistCredit []ArtistCredit `json:"artist-credit"`
|
||||
Disambiguation string
|
||||
FirstReleaseDate string `json:"first-release-date"`
|
||||
PrimaryType string `json:"primary-type"`
|
||||
PrimaryTypeId uuid.UUID `json:"primary-type-id"`
|
||||
SecondaryTypes []string `json:"secondary-types"`
|
||||
SecondaryTypeIds []uuid.UUID `json:"secondary-type-ids"`
|
||||
}
|
||||
|
||||
type ArtistCredit struct {
|
||||
Name string
|
||||
Artist Artist
|
||||
Name string
|
||||
Artist Artist
|
||||
JoinPhrase string
|
||||
}
|
||||
|
||||
type Artist struct {
|
||||
|
|
@ -95,6 +132,7 @@ type Artist struct {
|
|||
type Media struct {
|
||||
FormatId uuid.UUID `json:"format-id"`
|
||||
Position int
|
||||
Title string
|
||||
TrackOffset int `json:"track-offset"`
|
||||
Format string
|
||||
TrackCount int `json:"track-count"`
|
||||
|
|
@ -109,6 +147,25 @@ type Track struct {
|
|||
Length int
|
||||
}
|
||||
|
||||
func GetReleaseWithMedia(id uuid.UUID) (Release, error) {
|
||||
rel := Release{Id: id}
|
||||
url := fmt.Sprintf("https://musicbrainz.org/ws/2/release/%s", id)
|
||||
resp, err := h.GetWithQuery(url, u.Values{
|
||||
"fmt": []string{"json"},
|
||||
"inc": []string{"artist-credits+discids+labels+release-groups"}})
|
||||
if err != nil {
|
||||
return rel, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return rel, err
|
||||
}
|
||||
err = json.Unmarshal(body, &rel)
|
||||
|
||||
return rel, err
|
||||
}
|
||||
|
||||
func GetRecording(id string) (Recording, error) {
|
||||
u, err := uuid.Parse(id)
|
||||
rec := Recording{Id: u}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"codeberg.org/danjones000/strip-beats/config"
|
||||
"codeberg.org/danjones000/strip-beats/media/brainz"
|
||||
h "codeberg.org/danjones000/strip-beats/utils/http"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type FPrint struct {
|
||||
|
|
@ -45,7 +46,7 @@ type IdResults struct {
|
|||
}
|
||||
|
||||
type IdResult struct {
|
||||
Id string
|
||||
Id uuid.UUID
|
||||
Score float64
|
||||
Recordings []brainz.Recording
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import (
|
|||
)
|
||||
|
||||
type Tags struct {
|
||||
MajorBrand string `json:"major_brand"`
|
||||
Title string
|
||||
Artist string
|
||||
AlbumArtist string `json:"album_artist"`
|
||||
Album string
|
||||
Date string
|
||||
Encoder string
|
||||
Comment string
|
||||
Description string
|
||||
Synopsis string
|
||||
|
|
@ -21,12 +19,17 @@ type Tags struct {
|
|||
MusicbrainzAlbumId uuid.UUID `json:"MUSICBRAINZ_ALBUMID"`
|
||||
MusicbrainzAlbumArtistId uuid.UUID `json:"MUSICBRAINZ_ALBUMARTISTID"`
|
||||
MusicbrainzRecordingId uuid.UUID
|
||||
MusicBrainzLabelId uuid.UUID
|
||||
ArtistSort string
|
||||
AlbumArtistSort string
|
||||
ReleaseCountry string
|
||||
Label string
|
||||
ReleaseType string
|
||||
Composer string
|
||||
Genre string
|
||||
Disc string
|
||||
Track string
|
||||
Disc int `json:"-"`
|
||||
DiscCount int
|
||||
Track int `json:"-"`
|
||||
TrackCount int
|
||||
TrackStr string `json:"track"`
|
||||
DiscStr string `json:"disc"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue