added stuff, broke some other stuff, made admin auth!
Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
parent
0d1e694b59
commit
5631c4bd87
26 changed files with 1615 additions and 1401 deletions
|
@ -1,33 +1,37 @@
|
|||
package music
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"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)
|
||||
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 res
|
||||
}
|
||||
return nil, errors.New(fmt.Sprintf("Release %s not found", id))
|
||||
}
|
||||
|
||||
func GetRelease(id string) (MusicRelease, bool) {
|
||||
for _, album := range placeholders {
|
||||
if album.Id == id {
|
||||
return album, true
|
||||
}
|
||||
func GetArtist(id string) (*Artist, error) {
|
||||
for _, artist := range Artists {
|
||||
if artist.Id == id {
|
||||
return artist, nil
|
||||
}
|
||||
return MusicRelease{}, false
|
||||
}
|
||||
return nil, errors.New(fmt.Sprintf("Artist %s not found", id))
|
||||
}
|
||||
|
||||
func QueryAllMusic() ([]MusicRelease) {
|
||||
return placeholders
|
||||
}
|
||||
|
||||
func QueryAllArtists() ([]Artist) {
|
||||
return []Artist{ ari, mellodoot, zaire, mae, loudar, red }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
package music
|
||||
|
||||
var ari = Artist{
|
||||
Id: "arimelody",
|
||||
Name: "ari melody",
|
||||
Website: "https://arimelody.me",
|
||||
}
|
||||
var mellodoot = Artist{
|
||||
Id: "mellodoot",
|
||||
Name: "mellodoot",
|
||||
Website: "https://mellodoot.com",
|
||||
}
|
||||
var zaire = Artist{
|
||||
Id: "zaire",
|
||||
Name: "zaire",
|
||||
Website: "https://supitszaire.com",
|
||||
}
|
||||
var mae = Artist{
|
||||
Id: "maetaylor",
|
||||
Name: "mae taylor",
|
||||
Website: "https://mae.wtf",
|
||||
}
|
||||
var loudar = Artist{
|
||||
Id: "loudar",
|
||||
Name: "Loudar",
|
||||
Website: "https://alex.targoninc.com",
|
||||
}
|
||||
var red = Artist {
|
||||
Id: "smoljorb",
|
||||
Name: "smoljorb",
|
||||
}
|
||||
|
||||
var placeholders = []MusicRelease{
|
||||
{
|
||||
Id: "test",
|
||||
Title: "test album",
|
||||
Type: "album",
|
||||
ReleaseDate: make_date_work("18-Mar-2024"),
|
||||
Buyname: "go get it!!",
|
||||
Buylink: "https://arimelody.me/",
|
||||
Links: []MusicLink{
|
||||
{
|
||||
Name: "youtube",
|
||||
Url: "https://youtu.be/dQw4w9WgXcQ",
|
||||
},
|
||||
},
|
||||
Description:
|
||||
`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas viverra ligula interdum, tempor metus venenatis, tempus est. Praesent semper vulputate nulla, a venenatis libero elementum id. Proin maximus aliquet accumsan. Integer eu orci congue, ultrices leo sed, maximus risus. Integer laoreet non urna non accumsan. Cras ut sollicitudin justo. Vivamus eu orci tempus, aliquet est rhoncus, tempus neque. Aliquam tempor sit amet nibh sed tempus. Nulla vitae bibendum purus. Sed in mi enim. Nam pharetra enim lorem, vel tristique diam malesuada a. Duis dignissim nunc mi, id semper ex tincidunt a. Sed laoreet consequat lacus a consectetur. Nulla est diam, tempus eget lacus ullamcorper, tincidunt faucibus ex. Duis consectetur felis sit amet ante fermentum interdum. Sed pulvinar laoreet tellus.`,
|
||||
Credits: []MusicCredit{
|
||||
{
|
||||
Artist: &ari,
|
||||
Role: "having the swag",
|
||||
},
|
||||
{
|
||||
Artist: &zaire,
|
||||
Role: "having the swag",
|
||||
},
|
||||
{
|
||||
Artist: &mae,
|
||||
Role: "having the swag",
|
||||
},
|
||||
{
|
||||
Artist: &loudar,
|
||||
Role: "having the swag",
|
||||
},
|
||||
},
|
||||
Tracks: []MusicTrack{
|
||||
{
|
||||
Number: 0,
|
||||
Title: "track 1",
|
||||
Description: "sample track description",
|
||||
Lyrics: "sample lyrics for track 1!",
|
||||
PreviewUrl: "https://mellodoot.com/audio/preview/dream.webm",
|
||||
},
|
||||
{
|
||||
Number: 1,
|
||||
Title: "track 2",
|
||||
Description: "sample track description",
|
||||
Lyrics: "sample lyrics for track 2!",
|
||||
PreviewUrl: "https://mellodoot.com/audio/preview/dream.webm",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "dream",
|
||||
Title: "Dream",
|
||||
Type: "single",
|
||||
ReleaseDate: make_date_work("11-Nov-2022"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Dream.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/dream",
|
||||
Links: []MusicLink{
|
||||
{
|
||||
Name: "spotify",
|
||||
Url: "https://open.spotify.com/album/5talRpqzjExP1w6j5LFIAh",
|
||||
},
|
||||
{
|
||||
Name: "apple music",
|
||||
Url: "https://music.apple.com/ie/album/dream-single/1650037132",
|
||||
},
|
||||
{
|
||||
Name: "soundcloud",
|
||||
Url: "https://soundcloud.com/arimelody/dream2022",
|
||||
},
|
||||
{
|
||||
Name: "youtube",
|
||||
Url: "https://www.youtube.com/watch?v=nfFgtMuYAx8",
|
||||
},
|
||||
},
|
||||
Description: "living the dream 🌌 ✨",
|
||||
Credits: []MusicCredit{
|
||||
{
|
||||
Artist: &mellodoot,
|
||||
Role: "vocals",
|
||||
},
|
||||
{
|
||||
Artist: &mellodoot,
|
||||
Role: "production",
|
||||
},
|
||||
{
|
||||
Artist: &mellodoot,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
Tracks: []MusicTrack{
|
||||
{
|
||||
Number: 0,
|
||||
Title: "Dream",
|
||||
Description: "no description here!",
|
||||
Lyrics:
|
||||
`the truth is what you make of it
|
||||
in the end, what you spend, is the end of it
|
||||
when you're lost in the life
|
||||
the life that you created on your own
|
||||
i'm becoming one
|
||||
with the soul that i see in the mirror
|
||||
blending one and whole
|
||||
this time, i'm real
|
||||
|
||||
i'm living the dream
|
||||
i'm living my best life
|
||||
running out of time
|
||||
i gotta make this right
|
||||
whenever you rise
|
||||
whenever you come down
|
||||
fall away from the light
|
||||
and then fall into our arms
|
||||
|
||||
the truth is what you make of it
|
||||
in the end, what you spend, is the end of it
|
||||
when you're lost in the life
|
||||
the life that you created on your own
|
||||
i'm becoming one
|
||||
with the soul that i see in the mirror
|
||||
blending one and whole
|
||||
this time, i'm real`,
|
||||
PreviewUrl: "https://mellodoot.com/audio/preview/dream.webm",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,136 +1,133 @@
|
|||
package music
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
Artist struct {
|
||||
Id string
|
||||
Name string
|
||||
Website string
|
||||
}
|
||||
Artist struct {
|
||||
Id string
|
||||
Name string
|
||||
Website string
|
||||
}
|
||||
|
||||
MusicRelease struct {
|
||||
Id string
|
||||
Title string
|
||||
Type string
|
||||
ReleaseDate time.Time
|
||||
Artwork string
|
||||
Buyname string
|
||||
Buylink string
|
||||
Links []MusicLink
|
||||
Description string
|
||||
Credits []MusicCredit
|
||||
Tracks []MusicTrack
|
||||
}
|
||||
MusicRelease struct {
|
||||
Id string
|
||||
Title string
|
||||
Type string
|
||||
ReleaseDate time.Time
|
||||
Artwork string
|
||||
Buyname string
|
||||
Buylink string
|
||||
Links []MusicLink
|
||||
Description string
|
||||
Credits []MusicCredit
|
||||
Tracks []MusicTrack
|
||||
}
|
||||
|
||||
MusicLink struct {
|
||||
Name string
|
||||
Url string
|
||||
}
|
||||
MusicLink struct {
|
||||
Name string
|
||||
Url string
|
||||
}
|
||||
|
||||
MusicCredit struct {
|
||||
Artist *Artist
|
||||
Role string
|
||||
Meta bool // for "meta" contributors (i.e. not credited for the musical work, but other related assets)
|
||||
}
|
||||
MusicCredit struct {
|
||||
Artist *Artist
|
||||
Role string
|
||||
Primary bool
|
||||
}
|
||||
|
||||
MusicTrack struct {
|
||||
Number int
|
||||
Title string
|
||||
Description string
|
||||
Lyrics string
|
||||
PreviewUrl string
|
||||
}
|
||||
MusicTrack struct {
|
||||
Number int
|
||||
Title string
|
||||
Description string
|
||||
Lyrics string
|
||||
PreviewUrl string
|
||||
}
|
||||
)
|
||||
|
||||
func (release MusicRelease) GetUniqueArtists(include_meta bool) []*Artist {
|
||||
res := []*Artist{}
|
||||
for _, credit := range release.Credits {
|
||||
if !include_meta && credit.Meta {
|
||||
continue
|
||||
}
|
||||
|
||||
exists := false
|
||||
for _, a := range res {
|
||||
if a == credit.Artist {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if exists {
|
||||
continue
|
||||
}
|
||||
|
||||
res = append(res, credit.Artist)
|
||||
func (release MusicRelease) GetUniqueArtists(include_non_primary bool) []*Artist {
|
||||
res := []*Artist{}
|
||||
for _, credit := range release.Credits {
|
||||
if !include_non_primary && !credit.Primary {
|
||||
continue
|
||||
}
|
||||
|
||||
// now create the actual array to send
|
||||
return res
|
||||
exists := false
|
||||
for _, a := range res {
|
||||
if a == credit.Artist {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if exists {
|
||||
continue
|
||||
}
|
||||
|
||||
res = append(res, credit.Artist)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func (release MusicRelease) GetUniqueArtistNames(include_meta bool) []string {
|
||||
artists := release.GetUniqueArtists(include_meta)
|
||||
names := []string{}
|
||||
for _, artist := range artists {
|
||||
names = append(names, artist.Name)
|
||||
}
|
||||
func (release MusicRelease) GetUniqueArtistNames(include_non_primary bool) []string {
|
||||
artists := release.GetUniqueArtists(include_non_primary)
|
||||
names := []string{}
|
||||
for _, artist := range artists {
|
||||
names = append(names, artist.Name)
|
||||
}
|
||||
|
||||
return names
|
||||
return names
|
||||
}
|
||||
|
||||
func (album MusicRelease) PrintPrimaryArtists(include_meta bool) string {
|
||||
names := album.GetUniqueArtistNames(include_meta)
|
||||
if len(names) == 1 {
|
||||
return names[0]
|
||||
}
|
||||
func (release MusicRelease) PrintPrimaryArtists(include_non_primary bool, ampersand bool) string {
|
||||
names := release.GetUniqueArtistNames(include_non_primary)
|
||||
if len(names) == 0 {
|
||||
return "Unknown Artist"
|
||||
} else if len(names) == 1 {
|
||||
return names[0]
|
||||
}
|
||||
if ampersand {
|
||||
res := strings.Join(names[:len(names)-1], ", ")
|
||||
res += " & " + names[len(names)-1]
|
||||
return res
|
||||
}
|
||||
|
||||
func (album MusicRelease) PrintCommaPrimaryArtists(include_meta bool) string {
|
||||
names := album.GetUniqueArtistNames(include_meta)
|
||||
if len(names) == 1 {
|
||||
return names[0]
|
||||
}
|
||||
} else {
|
||||
return strings.Join(names[:], ", ")
|
||||
}
|
||||
}
|
||||
|
||||
func (album MusicRelease) ResolveType() string {
|
||||
if album.Type != "" {
|
||||
return album.Type
|
||||
}
|
||||
return "unknown"
|
||||
func (release MusicRelease) ResolveType() string {
|
||||
if release.Type != "" {
|
||||
return release.Type
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (album MusicRelease) ResolveArtwork() string {
|
||||
if album.Artwork != "" {
|
||||
return album.Artwork
|
||||
}
|
||||
return "/img/music-artwork/default.png"
|
||||
func (release MusicRelease) ResolveArtwork() string {
|
||||
if release.Artwork != "" {
|
||||
return release.Artwork
|
||||
}
|
||||
return "/img/music-artwork/default.png"
|
||||
}
|
||||
|
||||
func (album MusicRelease) PrintReleaseDate() string {
|
||||
return album.ReleaseDate.Format("02 January 2006")
|
||||
func (release MusicRelease) PrintReleaseDate() string {
|
||||
return release.ReleaseDate.Format("02 January 2006")
|
||||
}
|
||||
|
||||
func (album MusicRelease) GetReleaseYear() int {
|
||||
return album.ReleaseDate.Year()
|
||||
func (release MusicRelease) GetReleaseYear() int {
|
||||
return release.ReleaseDate.Year()
|
||||
}
|
||||
|
||||
func (link MusicLink) NormaliseName() string {
|
||||
re := regexp.MustCompile(`[^a-z0-9]`)
|
||||
return strings.ToLower(re.ReplaceAllString(link.Name, ""))
|
||||
re := regexp.MustCompile(`[^a-z0-9]`)
|
||||
return strings.ToLower(re.ReplaceAllString(link.Name, ""))
|
||||
}
|
||||
|
||||
func (release MusicRelease) IsSingle() bool {
|
||||
return len(release.Tracks) == 1;
|
||||
return len(release.Tracks) == 1;
|
||||
}
|
||||
|
||||
func (credit MusicCredit) ResolveArtist() Artist {
|
||||
return *credit.Artist
|
||||
return *credit.Artist
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue