2024-08-02 21:48:26 +00:00
|
|
|
package global
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"arimelody.me/arimelody.me/music/model"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
)
|
|
|
|
|
|
|
|
var HTTP_DOMAIN = func() string {
|
|
|
|
envvar := os.Getenv("HTTP_DOMAIN")
|
|
|
|
if envvar != "" {
|
|
|
|
return envvar
|
|
|
|
}
|
|
|
|
return "https://arimelody.me"
|
|
|
|
}
|
|
|
|
|
|
|
|
var DB *sqlx.DB
|
|
|
|
|
2024-08-02 23:27:30 +00:00
|
|
|
var Releases []*model.Release
|
|
|
|
var Artists []*model.Artist
|
|
|
|
var Tracks []*model.Track
|
2024-08-02 21:48:26 +00:00
|
|
|
|
|
|
|
func GetRelease(id string) *model.Release {
|
|
|
|
for _, release := range Releases {
|
|
|
|
if release.ID == id {
|
2024-08-02 23:27:30 +00:00
|
|
|
return release
|
2024-08-02 21:48:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetArtist(id string) *model.Artist {
|
|
|
|
for _, artist := range Artists {
|
|
|
|
if artist.ID == id {
|
2024-08-02 23:27:30 +00:00
|
|
|
return artist
|
2024-08-02 21:48:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-03 22:24:15 +00:00
|
|
|
|
|
|
|
func GetTrack(id string) *model.Track {
|
|
|
|
for _, track := range Tracks {
|
|
|
|
if track.ID == id {
|
|
|
|
return track
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|