add artists list to /api/v1/music
This commit is contained in:
parent
bc1b6c5872
commit
e69cf78e57
|
@ -7,7 +7,7 @@ tmp_dir = "tmp"
|
||||||
bin = "./tmp/main"
|
bin = "./tmp/main"
|
||||||
cmd = "go build -o ./tmp/main ."
|
cmd = "go build -o ./tmp/main ."
|
||||||
delay = 1000
|
delay = 1000
|
||||||
exclude_dir = ["admin\\static", "public", "uploads", "test"]
|
exclude_dir = ["admin/static", "public", "uploads", "test", "db"]
|
||||||
exclude_file = []
|
exclude_file = []
|
||||||
exclude_regex = ["_test.go"]
|
exclude_regex = ["_test.go"]
|
||||||
exclude_unchanged = false
|
exclude_unchanged = false
|
||||||
|
|
|
@ -27,6 +27,7 @@ func ServeCatalog() http.Handler {
|
||||||
type Release struct {
|
type Release struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
Artists []string `json:"artists"`
|
||||||
ReleaseType model.ReleaseType `json:"type" db:"type"`
|
ReleaseType model.ReleaseType `json:"type" db:"type"`
|
||||||
ReleaseDate time.Time `json:"releaseDate" db:"release_date"`
|
ReleaseDate time.Time `json:"releaseDate" db:"release_date"`
|
||||||
Artwork string `json:"artwork"`
|
Artwork string `json:"artwork"`
|
||||||
|
@ -40,9 +41,15 @@ func ServeCatalog() http.Handler {
|
||||||
if !release.Visible && !authorised {
|
if !release.Visible && !authorised {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
artists := []string{}
|
||||||
|
for _, credit := range release.Credits {
|
||||||
|
if !credit.Primary { continue }
|
||||||
|
artists = append(artists, credit.Artist.Name)
|
||||||
|
}
|
||||||
catalog = append(catalog, Release{
|
catalog = append(catalog, Release{
|
||||||
ID: release.ID,
|
ID: release.ID,
|
||||||
Title: release.Title,
|
Title: release.Title,
|
||||||
|
Artists: artists,
|
||||||
ReleaseType: release.ReleaseType,
|
ReleaseType: release.ReleaseType,
|
||||||
ReleaseDate: release.ReleaseDate,
|
ReleaseDate: release.ReleaseDate,
|
||||||
Artwork: release.Artwork,
|
Artwork: release.Artwork,
|
||||||
|
|
|
@ -66,7 +66,6 @@ func GetAllReleases(db *sqlx.DB, onlyVisible bool, limit int, full bool) ([]*mod
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if full {
|
|
||||||
for _, release := range releases {
|
for _, release := range releases {
|
||||||
// get credits
|
// get credits
|
||||||
credits, err := GetReleaseCredits(db, release.ID)
|
credits, err := GetReleaseCredits(db, release.ID)
|
||||||
|
@ -77,6 +76,7 @@ func GetAllReleases(db *sqlx.DB, onlyVisible bool, limit int, full bool) ([]*mod
|
||||||
release.Credits = append(release.Credits, credit)
|
release.Credits = append(release.Credits, credit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if full {
|
||||||
// get tracks
|
// get tracks
|
||||||
tracks, err := GetReleaseTracks(db, release.ID)
|
tracks, err := GetReleaseTracks(db, release.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue