renamed albums to music releases

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-03-20 10:50:37 +00:00
parent 9d56ca63af
commit 6ec813dd58
4 changed files with 135 additions and 135 deletions

View file

@ -44,7 +44,7 @@ func make_date_work(date string) time.Time {
return res
}
var placeholders = []Album{
var placeholders = []MusicRelease{
{
Id: "test",
Title: "test album",
@ -52,28 +52,28 @@ var placeholders = []Album{
ReleaseDate: make_date_work("18-Mar-2024"),
Buyname: "go get it!!",
Buylink: "https://arimelody.me/",
Links: []AlbumLink{
AlbumLink{
Links: []MusicLink{
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: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &ari,
Role: "having the swag",
},
AlbumCredit{
MusicCredit{
Artist: &zaire,
Role: "having the swag",
},
AlbumCredit{
MusicCredit{
Artist: &mae,
Role: "having the swag",
},
AlbumCredit{
MusicCredit{
Artist: &loudar,
Role: "having the swag",
},
@ -183,35 +183,35 @@ var placeholders = []Album{
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: []AlbumLink{
AlbumLink{
Links: []MusicLink{
MusicLink{
Name: "spotify",
Url: "https://open.spotify.com/album/5talRpqzjExP1w6j5LFIAh",
},
AlbumLink{
MusicLink{
Name: "apple music",
Url: "https://music.apple.com/ie/album/dream-single/1650037132",
},
AlbumLink{
MusicLink{
Name: "soundcloud",
Url: "https://soundcloud.com/arimelody/dream2022",
},
AlbumLink{
MusicLink{
Name: "youtube",
Url: "https://www.youtube.com/watch?v=nfFgtMuYAx8",
},
},
Description: "living the dream 🌌 ✨",
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "vocals",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -251,35 +251,35 @@ var placeholders = []Album{
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{
AlbumLink{
Links: []MusicLink{
MusicLink{
Name: "spotify",
Url: "https://open.spotify.com/album/35WNtxK12IDHCUoXHDePGE",
},
AlbumLink{
MusicLink{
Name: "apple music",
Url: "https://music.apple.com/ie/album/go-my-way-single/1547145699",
},
AlbumLink{
MusicLink{
Name: "soundcloud",
Url: "https://soundcloud.com/arimelody/go-my-way",
},
AlbumLink{
MusicLink{
Name: "youtube",
Url: "https://www.youtube.com/watch?v=CNptNQdLkl0",
},
},
Description: "hey! go my way! 💥 ✨",
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "vocals",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -292,7 +292,7 @@ var placeholders = []Album{
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{
Links: []MusicLink{
{
Name: "spotify",
Url: "https://open.spotify.com/album/7jyqJFVKaENCPm58v5O44Y",
@ -311,16 +311,16 @@ var placeholders = []Album{
},
},
Description: "let's take a trip. i've got a goddamn boat ⛵️",
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "vocals",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -333,7 +333,7 @@ var placeholders = []Album{
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{
Links: []MusicLink{
{
Name: "spotify",
Url: "https://open.spotify.com/album/3LbElPXD4dsDumttGBuYxx",
@ -352,16 +352,16 @@ var placeholders = []Album{
},
},
Description: "we'll dawn a new frontier! 👾",
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "vocals",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -373,7 +373,7 @@ var placeholders = []Album{
Type: "single",
ReleaseDate: make_date_work("07-Dec-2019"),
Artwork: "https://mellodoot.com/img/music_artwork/zaire_-_Sine_ft._mellodoot.webp",
Links: []AlbumLink{
Links: []MusicLink{
{
Name: "spotify",
Url: "https://open.spotify.com/album/4WPuaJtTV7z86KubD9Rnmk",
@ -387,12 +387,12 @@ var placeholders = []Album{
Url: "https://www.youtube.com/watch?v=z1H1s6VRnyY",
},
},
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &zaire,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
@ -405,7 +405,7 @@ var placeholders = []Album{
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{
Links: []MusicLink{
{
Name: "spotify",
Url: "https://open.spotify.com/album/2x4gbACfDm99unaXpLXyj0",
@ -423,12 +423,12 @@ var placeholders = []Album{
Url: "https://www.youtube.com/watch?v=C7WP5L2BK4U",
},
},
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -441,7 +441,7 @@ var placeholders = []Album{
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{
Links: []MusicLink{
{
Name: "spotify",
Url: "https://open.spotify.com/album/59nFXw1WNoRhXou7lXqBZd",
@ -459,16 +459,16 @@ var placeholders = []Album{
Url: "https://www.youtube.com/watch?v=OB-Pk6p6mfQ",
},
},
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "vocals",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -481,7 +481,7 @@ var placeholders = []Album{
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{
Links: []MusicLink{
{
Name: "spotify",
Url: "https://open.spotify.com/album/3EPa4HZpkISQVRAks64LfR",
@ -499,12 +499,12 @@ var placeholders = []Album{
Url: "https://www.youtube.com/playlist?list=PLBG_QJeOHrB5EeniiXBIlHpoQbD6CUJca",
},
},
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -535,7 +535,7 @@ var placeholders = []Album{
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",
Links: []AlbumLink{
Links: []MusicLink{
{
Name: "soundcloud",
Url: "https://soundcloud.com/arimelody/how-they-know-2018",
@ -545,12 +545,12 @@ var placeholders = []Album{
Url: "https://www.youtube.com/watch?v=mbAgSwCzyMw",
},
},
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &red,
Role: "artwork",
Meta: true,
@ -565,7 +565,7 @@ var placeholders = []Album{
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_How_They_Know.webp",
Buyname: "free download",
Buylink: "https://arimelody.bandcamp.com/track/how-they-know",
Links: []AlbumLink{
Links: []MusicLink{
{
Name: "soundcloud",
Url: "https://soundcloud.com/arimelody/how-they-know",
@ -575,12 +575,12 @@ var placeholders = []Album{
Url: "https://www.youtube.com/watch?v=q6lzKuG1Emo",
},
},
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &red,
Role: "artwork",
Meta: true,
@ -595,7 +595,7 @@ var placeholders = []Album{
Artwork: "https://mellodoot.com/img/music_artwork/mellodoot_-_Traveller.webp",
Buyname: "free download",
Buylink: "https://arimelody.bandcamp.com/track/traveller",
Links: []AlbumLink{
Links: []MusicLink{
{
Name: "soundcloud",
Url: "https://soundcloud.com/arimelody/traveller",
@ -606,12 +606,12 @@ var placeholders = []Album{
},
},
Description: "an 8-bit expedition! ⚔️🛡️",
Credits: []AlbumCredit{
AlbumCredit{
Credits: []MusicCredit{
MusicCredit{
Artist: &mellodoot,
Role: "production",
},
AlbumCredit{
MusicCredit{
Artist: &mellodoot,
Role: "artwork",
},
@ -619,16 +619,16 @@ var placeholders = []Album{
},
}
func GetAlbum(id string) (Album, bool) {
func GetAlbum(id string) (MusicRelease, bool) {
for _, album := range placeholders {
if album.Id == id {
return album, true
}
}
return Album{}, false
return MusicRelease{}, false
}
func QueryAllAlbums() ([]Album) {
func QueryAllAlbums() ([]MusicRelease) {
return placeholders
}

View file

@ -8,38 +8,38 @@ import (
type (
Artist struct {
Id string;
Name string;
Website string;
Id string
Name string
Website string
}
Album struct {
Id string;
Title string;
Type string;
ReleaseDate time.Time;
Artwork string;
Buyname string;
Buylink string;
Links []AlbumLink;
Description string;
Credits []AlbumCredit;
Lyrics string;
MusicRelease struct {
Id string
Title string
Type string
ReleaseDate time.Time
Artwork string
Buyname string
Buylink string
Links []MusicLink
Description string
Credits []MusicCredit
Lyrics string
}
AlbumLink struct {
Name string;
Url string;
MusicLink struct {
Name string
Url string
}
AlbumCredit 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
Meta bool // for "meta" contributors (i.e. not credited for the musical work, but other related assets)
}
)
func (album Album) GetUniqueArtists() []Artist {
func (album MusicRelease) GetUniqueArtists() []Artist {
if len(album.Credits) == 1 {
return []Artist{*album.Credits[0].Artist}
}
@ -65,7 +65,7 @@ func (album Album) GetUniqueArtists() []Artist {
return res
}
func (album Album) GetUniqueNonMetaArtists() []Artist {
func (album MusicRelease) GetUniqueNonMetaArtists() []Artist {
if len(album.Credits) == 1 {
return []Artist{*album.Credits[0].Artist}
}
@ -94,7 +94,7 @@ func (album Album) GetUniqueNonMetaArtists() []Artist {
return res
}
func (album Album) GetUniqueArtistNames() []string {
func (album MusicRelease) GetUniqueArtistNames() []string {
if len(album.Credits) == 1 {
return []string{album.Credits[0].Artist.Name}
}
@ -105,10 +105,10 @@ func (album Album) GetUniqueArtistNames() []string {
names = append(names, artist.Name)
}
return names;
return names
}
func (album Album) GetUniqueNonMetaArtistNames() []string {
func (album MusicRelease) GetUniqueNonMetaArtistNames() []string {
if len(album.Credits) == 1 {
return []string{album.Credits[0].Artist.Name}
}
@ -119,11 +119,11 @@ func (album Album) GetUniqueNonMetaArtistNames() []string {
names = append(names, artist.Name)
}
return names;
return names
}
func (album Album) PrintPrimaryArtists() string {
names := album.GetUniqueNonMetaArtistNames();
func (album MusicRelease) PrintPrimaryArtists() string {
names := album.GetUniqueNonMetaArtistNames()
if len(names) == 1 {
return names[0]
}
@ -132,41 +132,41 @@ func (album Album) PrintPrimaryArtists() string {
return res
}
func (album Album) PrintCommaPrimaryArtists() string {
names := album.GetUniqueNonMetaArtistNames();
func (album MusicRelease) PrintCommaPrimaryArtists() string {
names := album.GetUniqueNonMetaArtistNames()
if len(names) == 1 {
return names[0]
}
return strings.Join(names[:len(names)], ", ")
return strings.Join(names[:], ", ")
}
func (album Album) ResolveType() string {
func (album MusicRelease) ResolveType() string {
if album.Type != "" {
return album.Type
}
return "unknown"
}
func (album Album) ResolveArtwork() string {
func (album MusicRelease) ResolveArtwork() string {
if album.Artwork != "" {
return album.Artwork
}
return "/img/music-artwork/default.png"
}
func (album Album) PrintReleaseDate() string {
func (album MusicRelease) PrintReleaseDate() string {
return album.ReleaseDate.Format("02 January 2006")
}
func (album Album) GetReleaseYear() int {
func (album MusicRelease) GetReleaseYear() int {
return album.ReleaseDate.Year()
}
func (link AlbumLink) NormaliseName() string {
func (link MusicLink) NormaliseName() string {
re := regexp.MustCompile(`[^a-z0-9]`)
return strings.ToLower(re.ReplaceAllString(link.Name, ""))
}
func (credit AlbumCredit) ResolveArtist() Artist {
func (credit MusicCredit) ResolveArtist() Artist {
return *credit.Artist
}

38
db.go
View file

@ -12,13 +12,13 @@ import (
)
var schema =
`CREATE TABLE IF NOT EXISTS Artists (
`CREATE TABLE IF NOT EXISTS artists (
id TEXT PRIMARY KEY,
name TEXT,
website TEXT
);
CREATE TABLE IF NOT EXISTS Albums (
CREATE TABLE IF NOT EXISTS musicreleases (
id VARCHAR(64) PRIMARY KEY,
title TEXT NOT NULL,
type TEXT,
@ -30,19 +30,19 @@ CREATE TABLE IF NOT EXISTS Albums (
lyrics TEXT
);
CREATE TABLE IF NOT EXISTS AlbumLinks (
album VARCHAR(64) REFERENCES Albums(id) ON DELETE CASCADE ON UPDATE CASCADE,
CREATE TABLE IF NOT EXISTS musiclinks (
album VARCHAR(64) REFERENCES musicreleases(id) ON DELETE CASCADE ON UPDATE CASCADE,
name TEXT,
url TEXT,
CONSTRAINT albumlinks_pk PRIMARY KEY (album, name)
CONSTRAINT musiclinks_pk PRIMARY KEY (album, name)
);
CREATE TABLE IF NOT EXISTS AlbumCredits (
album VARCHAR(64) REFERENCES Albums(ID) ON DELETE CASCADE,
artist TEXT REFERENCES Artists(id) ON DELETE CASCADE,
CREATE TABLE IF NOT EXISTS musiccredits (
album VARCHAR(64) REFERENCES musicreleases(ID) ON DELETE CASCADE,
artist TEXT REFERENCES artists(id) ON DELETE CASCADE,
role TEXT,
meta BOOLEAN,
constraint albumcredits_pk PRIMARY KEY (album, artist, role)
constraint musiccredits_pk PRIMARY KEY (album, artist, role)
);`
func PushArtist(db *sqlx.DB, artist music.Artist) {
@ -57,21 +57,21 @@ func PushArtist(db *sqlx.DB, artist music.Artist) {
fmt.Printf("done!\n")
}
func PushAlbum(db *sqlx.DB, album music.Album) {
fmt.Printf("syncing album [%s] to database...", album.Id)
func PushRelease(db *sqlx.DB, release music.MusicRelease) {
fmt.Printf("syncing release [%s] to database...", release.Id)
tx := db.MustBegin()
tx.MustExec("INSERT INTO albums (id, title, release_date, artwork, buyname, buylink, description, lyrics) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) "+
tx.MustExec("INSERT INTO musicreleases (id, title, release_date, artwork, buyname, buylink, description, lyrics) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) "+
"ON CONFLICT (id) DO UPDATE SET title=$2, release_date=$3, artwork=$4, buyname=$5, buylink=$6, description=$7, lyrics=$8",
&album.Id, &album.Title, album.ReleaseDate.Format("2-Jan-2006"), &album.Artwork, &album.Buyname, &album.Buylink, &album.Description, &album.Lyrics)
&release.Id, &release.Title, release.ReleaseDate.Format("2-Jan-2006"), &release.Artwork, &release.Buyname, &release.Buylink, &release.Description, &release.Lyrics)
for _, link := range album.Links {
tx.MustExec("INSERT INTO albumlinks (album, name, url) VALUES ($1, $2, $3) ON CONFLICT (album, name) DO UPDATE SET url=$3",
&album.Id, &link.Name, &link.Url)
for _, link := range release.Links {
tx.MustExec("INSERT INTO musiclinks (album, name, url) VALUES ($1, $2, $3) ON CONFLICT (album, name) DO UPDATE SET url=$3",
&release.Id, &link.Name, &link.Url)
}
for _, credit := range album.Credits {
tx.MustExec("INSERT INTO albumcredits (album, artist, role, meta) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",
&album.Id, &credit.Artist.Id, &credit.Role, &credit.Meta)
for _, credit := range release.Credits {
tx.MustExec("INSERT INTO musiccredits (album, artist, role, meta) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",
&release.Id, &credit.Artist.Id, &credit.Role, &credit.Meta)
}
tx.Commit()

View file

@ -186,7 +186,7 @@ func push_to_db_this_is_a_testing_thing_and_will_be_superfluous_later() {
}
for _, album := range music.QueryAllAlbums() {
PushAlbum(db, album)
PushRelease(db, album)
}
defer db.Close()