arimelody.me/api/v1/music/music.go
ari melody 5631c4bd87 added stuff, broke some other stuff, made admin auth!
Signed-off-by: ari melody <ari@arimelody.me>
2024-08-31 01:52:31 +01:00

38 lines
835 B
Go

package music
import (
"errors"
"fmt"
"time"
)
var Releases []*MusicRelease;
var Artists []*Artist;
func make_date_work(date string) time.Time {
res, err := time.Parse("2-Jan-2006", date)
if err != nil {
fmt.Printf("somehow we failed to parse %s! falling back to epoch :]\n", date)
return time.Unix(0, 0)
}
return res
}
func GetRelease(id string) (*MusicRelease, error) {
for _, release := range Releases {
if release.Id == id {
return release, nil
}
}
return nil, errors.New(fmt.Sprintf("Release %s not found", id))
}
func GetArtist(id string) (*Artist, error) {
for _, artist := range Artists {
if artist.Id == id {
return artist, nil
}
}
return nil, errors.New(fmt.Sprintf("Artist %s not found", id))
}