early database work
Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
parent
6efd47c6c6
commit
5eecef1d78
8 changed files with 512 additions and 96 deletions
|
@ -1,19 +1,47 @@
|
|||
package music
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
var ari = Artist{
|
||||
Name: "ari melody",
|
||||
Website: "https://arimelody.me",
|
||||
}
|
||||
var zaire = Artist{
|
||||
Name: "zaire",
|
||||
Website: "https://supitszaire.com",
|
||||
}
|
||||
var mae = Artist{
|
||||
Name: "mae taylor",
|
||||
Website: "https://mae.wtf",
|
||||
}
|
||||
var loudar = Artist{
|
||||
Name: "Loudar",
|
||||
Website: "https://alex.targoninc.com",
|
||||
}
|
||||
var red = Artist{
|
||||
Name: "smoljorb",
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
var placeholders = []Album{
|
||||
{
|
||||
Id: "test",
|
||||
Title: "test album",
|
||||
Type: "album",
|
||||
Year: 2024,
|
||||
ReleaseDate: make_date_work("18-Mar-2024"),
|
||||
Buyname: "go get it!!",
|
||||
Buylink: "https://arimelody.me/",
|
||||
Artists: []string{
|
||||
"ari melody",
|
||||
"zaire",
|
||||
"mae taylor",
|
||||
"Loudar",
|
||||
},
|
||||
Links: []AlbumLink{
|
||||
AlbumLink{
|
||||
Name: "youtube",
|
||||
|
@ -23,23 +51,19 @@ var placeholders = []Album{
|
|||
Description: "she sample on my text 'til i 🚫🚫🚫",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Name: "ari melody",
|
||||
Url: "https://arimelody.me",
|
||||
Artist: &ari,
|
||||
Role: "having the swag",
|
||||
},
|
||||
AlbumCredit{
|
||||
Name: "zaire",
|
||||
Url: "https://supitszaire.com",
|
||||
Artist: &zaire,
|
||||
Role: "having the swag",
|
||||
},
|
||||
AlbumCredit{
|
||||
Name: "mae taylor",
|
||||
Url: "https://mae.wtf",
|
||||
Artist: &mae,
|
||||
Role: "having the swag",
|
||||
},
|
||||
AlbumCredit{
|
||||
Name: "Loudar",
|
||||
Url: "https://alex.targoninc.com",
|
||||
Artist: &loudar,
|
||||
Role: "having the swag",
|
||||
},
|
||||
},
|
||||
|
@ -122,21 +146,32 @@ var placeholders = []Album{
|
|||
Id: "free2play",
|
||||
Title: "free2play",
|
||||
Type: "upcoming",
|
||||
Year: 2024,
|
||||
ReleaseDate: make_date_work("17-Mar-2024"),
|
||||
Buyname: "pre-order",
|
||||
Buylink: "https://arimelody.me/",
|
||||
Artists: []string{ "ari melody" },
|
||||
Description: "hello from your local SPACEGIRL! 💫",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "vocals",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "dream",
|
||||
Title: "Dream",
|
||||
Type: "single",
|
||||
Year: 2022,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("11-Nov-2024"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Dream.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/dream",
|
||||
Free: false,
|
||||
Links: []AlbumLink{
|
||||
AlbumLink{
|
||||
Name: "spotify",
|
||||
|
@ -158,18 +193,15 @@ var placeholders = []Album{
|
|||
Description: "living the dream 🌌 ✨",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Name: "ari melody",
|
||||
Url: "https://arimelody.me",
|
||||
Artist: &ari,
|
||||
Role: "vocals",
|
||||
},
|
||||
AlbumCredit{
|
||||
Name: "ari melody",
|
||||
Url: "https://arimelody.me",
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Name: "ari melody",
|
||||
Url: "https://arimelody.me",
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
|
@ -205,8 +237,7 @@ var placeholders = []Album{
|
|||
Id: "gomyway",
|
||||
Title: "Go My Way",
|
||||
Type: "single",
|
||||
Year: 2021,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("24-Jan-2021"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Go_My_Way.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/go-my-way",
|
||||
Links: []AlbumLink{
|
||||
|
@ -228,13 +259,26 @@ var placeholders = []Album{
|
|||
},
|
||||
},
|
||||
Description: "hey! go my way! 💥 ✨",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "vocals",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "rowboat",
|
||||
Title: "Rowboat",
|
||||
Type: "single",
|
||||
Year: 2020,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("12-Mar-2020"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Rowboat.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/rowboat",
|
||||
Links: []AlbumLink{
|
||||
|
@ -256,13 +300,26 @@ var placeholders = []Album{
|
|||
},
|
||||
},
|
||||
Description: "let's take a trip. i've got a goddamn boat ⛵️",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "vocals",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "helloworld",
|
||||
Title: "Hello World",
|
||||
Type: "single",
|
||||
Year: 2019,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("25-Dec-2019"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Hello_World.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/hello-world",
|
||||
Links: []AlbumLink{
|
||||
|
@ -284,13 +341,26 @@ var placeholders = []Album{
|
|||
},
|
||||
},
|
||||
Description: "we'll dawn a new frontier! 👾",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "vocals",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "sine",
|
||||
Title: "Sine",
|
||||
Type: "single",
|
||||
Artists: []string{ "zaire", "mellodoot" },
|
||||
Year: 2019,
|
||||
ReleaseDate: make_date_work("07-Dec-2019"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/zaire_-_Sine_ft._mellodoot.webp",
|
||||
Links: []AlbumLink{
|
||||
{
|
||||
|
@ -306,13 +376,22 @@ var placeholders = []Album{
|
|||
Url: "https://www.youtube.com/watch?v=z1H1s6VRnyY",
|
||||
},
|
||||
},
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &zaire,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "10",
|
||||
Title: "10",
|
||||
Type: "single",
|
||||
Year: 2019,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("29-Sep-2019"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_10.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/10",
|
||||
Links: []AlbumLink{
|
||||
|
@ -333,13 +412,22 @@ var placeholders = []Album{
|
|||
Url: "https://www.youtube.com/watch?v=C7WP5L2BK4U",
|
||||
},
|
||||
},
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "mad",
|
||||
Title: "MAD",
|
||||
Type: "single",
|
||||
Year: 2018,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("03-Nov-2018"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_MAD.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/mad",
|
||||
Links: []AlbumLink{
|
||||
|
@ -360,13 +448,26 @@ var placeholders = []Album{
|
|||
Url: "https://www.youtube.com/watch?v=OB-Pk6p6mfQ",
|
||||
},
|
||||
},
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "vocals",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "welcomingparty",
|
||||
Title: "Welcoming Party",
|
||||
Type: "album",
|
||||
Year: 2018,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("01-Nov-2018"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Welcoming_Party.webp",
|
||||
Buylink: "https://arimelody.bandcamp.com/album/welcoming-party",
|
||||
Links: []AlbumLink{
|
||||
|
@ -387,6 +488,16 @@ var placeholders = []Album{
|
|||
Url: "https://www.youtube.com/playlist?list=PLBG_QJeOHrB5EeniiXBIlHpoQbD6CUJca",
|
||||
},
|
||||
},
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
// "tracks": [
|
||||
// {
|
||||
// "title": "Paradigm"
|
||||
|
@ -409,11 +520,10 @@ var placeholders = []Album{
|
|||
Id: "howtheyknow2018",
|
||||
Title: "How They Know (2018)",
|
||||
Type: "single",
|
||||
Year: 2018,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("27-Feb-2018"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_How_They_Know_2018.webp",
|
||||
Buyname: "free download",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/how-they-know-2018-remastered",
|
||||
Free: true,
|
||||
Links: []AlbumLink{
|
||||
{
|
||||
Name: "soundcloud",
|
||||
|
@ -424,16 +534,25 @@ var placeholders = []Album{
|
|||
Url: "https://www.youtube.com/watch?v=mbAgSwCzyMw",
|
||||
},
|
||||
},
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &red,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "howtheyknow",
|
||||
Title: "How They Know",
|
||||
Type: "single",
|
||||
Year: 2017,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("29-Nov-2017"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_How_They_Know.webp",
|
||||
Buyname: "free download",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/how-they-know",
|
||||
Free: true,
|
||||
Links: []AlbumLink{
|
||||
{
|
||||
Name: "soundcloud",
|
||||
|
@ -444,16 +563,25 @@ var placeholders = []Album{
|
|||
Url: "https://www.youtube.com/watch?v=q6lzKuG1Emo",
|
||||
},
|
||||
},
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &red,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Id: "traveller",
|
||||
Title: "Traveller",
|
||||
Type: "single",
|
||||
Year: 2017,
|
||||
Artists: []string{ "mellodoot" },
|
||||
ReleaseDate: make_date_work("24-Sep-2017"),
|
||||
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Traveller.webp",
|
||||
Buyname: "free download",
|
||||
Buylink: "https://arimelody.bandcamp.com/track/traveller",
|
||||
Free: true,
|
||||
Links: []AlbumLink{
|
||||
{
|
||||
Name: "soundcloud",
|
||||
|
@ -465,6 +593,16 @@ var placeholders = []Album{
|
|||
},
|
||||
},
|
||||
Description: "an 8-bit expedition! ⚔️🛡️",
|
||||
Credits: []AlbumCredit{
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "production",
|
||||
},
|
||||
AlbumCredit{
|
||||
Artist: &ari,
|
||||
Role: "artwork",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -477,7 +615,11 @@ func GetAlbum(id string) (Album, bool) {
|
|||
return Album{}, false
|
||||
}
|
||||
|
||||
func QueryAll() ([]Album) {
|
||||
func QueryAllAlbums() ([]Album) {
|
||||
return placeholders
|
||||
}
|
||||
|
||||
func QueryAllArtists() ([]Artist) {
|
||||
return []Artist{ ari, zaire, mae, loudar, red }
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,23 @@ package music
|
|||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
Artist struct {
|
||||
Name string;
|
||||
Website string;
|
||||
}
|
||||
|
||||
Album struct {
|
||||
Id string;
|
||||
Title string;
|
||||
Type string;
|
||||
Year int;
|
||||
Artists []string;
|
||||
ReleaseDate time.Time;
|
||||
Artwork string;
|
||||
Buyname string;
|
||||
Buylink string;
|
||||
Free bool;
|
||||
Links []AlbumLink;
|
||||
Description string;
|
||||
Credits []AlbumCredit;
|
||||
|
@ -28,26 +32,59 @@ type (
|
|||
}
|
||||
|
||||
AlbumCredit struct {
|
||||
Artist *Artist;
|
||||
Role string;
|
||||
Name string;
|
||||
Url string;
|
||||
}
|
||||
)
|
||||
|
||||
func (album Album) PrintArtists() string {
|
||||
if len(album.Artists) == 1 {
|
||||
return album.Artists[0]
|
||||
func (album Album) GetUniqueArtists() []Artist {
|
||||
if len(album.Credits) == 1 {
|
||||
return []Artist{ *album.Credits[0].Artist }
|
||||
}
|
||||
res := strings.Join(album.Artists[:len(album.Artists) - 1], ", ")
|
||||
res += " & " + album.Artists[len(album.Artists) - 1]
|
||||
|
||||
// create a map of artists to prevent duplicates
|
||||
m := map[string]Artist{}
|
||||
for _, credit := range album.Credits {
|
||||
artist := *credit.Artist
|
||||
m[artist.Name] = artist
|
||||
}
|
||||
|
||||
// now create the actual array to send
|
||||
res := []Artist{}
|
||||
for _, artist := range m {
|
||||
res = append(res, artist)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (album Album) PrintArtists() string {
|
||||
if len(album.Credits) == 1 {
|
||||
return album.Credits[0].Artist.Name
|
||||
}
|
||||
|
||||
artists := album.GetUniqueArtists()
|
||||
names := []string{}
|
||||
for _, artist := range artists {
|
||||
names = append(names, artist.Name)
|
||||
}
|
||||
|
||||
res := strings.Join(names[:len(names) - 1], ", ")
|
||||
res += " & " + names[len(names) - 1]
|
||||
return res
|
||||
}
|
||||
|
||||
func (album Album) PrintCommaArtists() string {
|
||||
if len(album.Artists) == 1 {
|
||||
return album.Artists[0]
|
||||
if len(album.Credits) == 1 {
|
||||
return album.Credits[0].Artist.Name
|
||||
}
|
||||
return strings.Join(album.Artists[:len(album.Artists)], ", ")
|
||||
|
||||
artists := album.GetUniqueArtists()
|
||||
names := []string{}
|
||||
for _, artist := range artists {
|
||||
names = append(names, artist.Name)
|
||||
}
|
||||
|
||||
return strings.Join(names[:len(names)], ", ")
|
||||
}
|
||||
|
||||
func (album Album) ResolveArtwork() string {
|
||||
|
@ -57,7 +94,15 @@ func (album Album) ResolveArtwork() string {
|
|||
return "/img/music-artwork/default.png"
|
||||
}
|
||||
|
||||
func (album Album) GetReleaseYear() int {
|
||||
return album.ReleaseDate.Year()
|
||||
}
|
||||
|
||||
func (link AlbumLink) NormaliseName() string {
|
||||
re := regexp.MustCompile(`[^a-z0-9]`)
|
||||
return strings.ToLower(re.ReplaceAllString(link.Name, ""))
|
||||
}
|
||||
|
||||
func (credit AlbumCredit) ResolveArtist() Artist {
|
||||
return *credit.Artist
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue