From 749f9bc8b71ff1b173b4507197ded7b1a764b57a Mon Sep 17 00:00:00 2001 From: ari melody Date: Sat, 23 Mar 2024 22:20:51 +0000 Subject: [PATCH] updated schema to support album tracks Signed-off-by: ari melody --- .gitattributes | 1 + api/v1/music/music.go | 605 ----------------------------- api/v1/music/music_placeholders.go | 161 ++++++++ api/v1/music/music_types.go | 94 ++--- db.go | 37 +- public/style/main.css | 21 + public/style/music-gateway.css | 147 +++---- public/style/music.css | 7 +- views/music-gateway.html | 53 ++- views/music.html | 4 +- 10 files changed, 324 insertions(+), 806 deletions(-) create mode 100644 api/v1/music/music_placeholders.go diff --git a/.gitattributes b/.gitattributes index 50fa4c5..e51dbf6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,5 +7,6 @@ *.mp3 filter=lfs diff=lfs merge=lfs -text *.mp4 filter=lfs diff=lfs merge=lfs -text *.svg filter=lfs diff=lfs merge=lfs -text +text eol=lf . !text !filter !merge !diff * !text !filter !merge !diff diff --git a/api/v1/music/music.go b/api/v1/music/music.go index 6aecb61..6e85be5 100644 --- a/api/v1/music/music.go +++ b/api/v1/music/music.go @@ -5,36 +5,6 @@ import ( "time" ) -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", -} - func make_date_work(date string) time.Time { res, err := time.Parse("2-Jan-2006", date) if err != nil { @@ -44,581 +14,6 @@ func make_date_work(date string) time.Time { return res } -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", - }, - }, - Lyrics: - `(call me when you fall asleep) - (all in, let me ride the wave) - - (okay!) - - call me - when you fall asleep - (fall asleep, call on me) - (oh babe, why don'cha) - yeah, it's how you feel - when the stars come out - (you're never gonna get it) - (while you've lost yourself in a rut) - all in - let me ride the wave - (i'm so stressed) - (i need to fly out of this place) - yeah, 'cause we can drift - 'til the break of dawn - (i think i'll be okay) - (if i can sleep today) - - (switch it up!) - - slumber party at 2AM - could think of nothing more perfect - than a moonlight jam - - yeah, i've got no sleep - but I'm free today - yeah you could even say - that i'm free2play - - you ain't here by my side - and i try to get by - with my head out the window - get a listen of this - - the whispers of the trees - the crickets do be chirpin' - i guess that's how it goes - - (call me when you fall asleep) - (all in, let me ride the wave) - - (let's go!) - - call me - when you fall asleep - (fall asleep, call on me) - (oh babe, why don'cha) - yeah, it's how you feel - when the stars come out - (you're never gonna get it) - (while you've lost yourself in a rut) - all in - let me ride the wave - (i'm so stressed) - (i need to fly out of this place) - yeah, 'cause we can drift - 'til the break of dawn - (i think i'll be okay) - (if i can sleep today) - - yeah... woo! - (BASS) - oh man... - i'm just sitting here - feeling the breeze - hanging out - listening to the crickets - and the trees in the breeze - living my best life`, - }, - // { - // Id: "free2play", - // Title: "free2play", - // Type: "upcoming", - // ReleaseDate: make_date_work("17-Mar-2024"), - // Buyname: "pre-order", - // Buylink: "https://arimelody.me/", - // 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", - 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", - }, - }, - 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`, - }, - { - Id: "gomyway", - Title: "Go My Way", - Type: "single", - 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: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/35WNtxK12IDHCUoXHDePGE", - }, - { - Name: "apple music", - Url: "https://music.apple.com/ie/album/go-my-way-single/1547145699", - }, - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/go-my-way", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=CNptNQdLkl0", - }, - }, - Description: "hey! go my way! 💥 ✨", - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "vocals", - }, - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - }, - { - Id: "rowboat", - Title: "Rowboat", - Type: "single", - 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: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/7jyqJFVKaENCPm58v5O44Y", - }, - { - Name: "apple music", - Url: "https://music.apple.com/ie/album/rowboat-single/1502608714", - }, - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/rowboat", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=uOQyILDTzME", - }, - }, - Description: "let's take a trip. i've got a goddamn boat ⛵️", - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "vocals", - }, - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - }, - { - Id: "helloworld", - Title: "Hello World", - Type: "single", - 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: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/3LbElPXD4dsDumttGBuYxx", - }, - { - Name: "apple music", - Url: "https://music.apple.com/ie/album/hello-world-single/1491880155", - }, - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/helloworld", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=CQhlRsl0Mjk", - }, - }, - Description: "we'll dawn a new frontier! 👾", - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "vocals", - }, - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - }, - { - Id: "sine", - Title: "Sine", - Type: "single", - ReleaseDate: make_date_work("07-Dec-2019"), - Artwork: "https://mellodoot.com/img/music_artwork/zaire_-_Sine_ft._mellodoot.webp", - Links: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/4WPuaJtTV7z86KubD9Rnmk", - }, - { - Name: "apple music", - Url: "https://music.apple.com/us/album/sine-feat-mellodoot/1489163020", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=z1H1s6VRnyY", - }, - }, - Credits: []MusicCredit{ - { - Artist: &zaire, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "production", - }, - }, - }, - { - Id: "10", - Title: "10", - Type: "single", - 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: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/2x4gbACfDm99unaXpLXyj0", - }, - { - Name: "apple music", - Url: "https://music.apple.com/ie/album/ten-single/1483193041", - }, - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/ten", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=C7WP5L2BK4U", - }, - }, - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - }, - { - Id: "mad", - Title: "MAD", - Type: "single", - 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: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/59nFXw1WNoRhXou7lXqBZd", - }, - { - Name: "apple music", - Url: "https://music.apple.com/ie/album/mad/1441233120", - }, - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/mad", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=OB-Pk6p6mfQ", - }, - }, - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "vocals", - }, - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - }, - { - Id: "welcomingparty", - Title: "Welcoming Party", - Type: "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: []MusicLink{ - { - Name: "spotify", - Url: "https://open.spotify.com/album/3EPa4HZpkISQVRAks64LfR", - }, - { - Name: "apple music", - Url: "https://music.apple.com/ie/album/welcoming-party-ep/1441161424", - }, - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/sets/welcoming-party", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/playlist?list=PLBG_QJeOHrB5EeniiXBIlHpoQbD6CUJca", - }, - }, - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - // "tracks": [ - // { - // "title": "Paradigm" - // }, - // { - // "title": "Mitrio" - // }, - // { - // "title": "Level One" - // }, - // { - // "title": "Cubes" - // }, - // { - // "title": "Aria" - // } - // ] - }, - { - Id: "howtheyknow2018", - Title: "How They Know (2018)", - Type: "single", - 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", - Links: []MusicLink{ - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/how-they-know-2018", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=mbAgSwCzyMw", - }, - }, - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &red, - Role: "artwork", - Meta: true, - }, - }, - }, - { - Id: "howtheyknow", - Title: "How They Know", - Type: "single", - 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", - Links: []MusicLink{ - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/how-they-know", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=q6lzKuG1Emo", - }, - }, - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &red, - Role: "artwork", - Meta: true, - }, - }, - }, - { - Id: "traveller", - Title: "Traveller", - Type: "single", - 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", - Links: []MusicLink{ - { - Name: "soundcloud", - Url: "https://soundcloud.com/arimelody/traveller", - }, - { - Name: "youtube", - Url: "https://www.youtube.com/watch?v=ZTO7IQZ-yXA", - }, - }, - Description: "an 8-bit expedition! ⚔️🛡️", - Credits: []MusicCredit{ - { - Artist: &mellodoot, - Role: "production", - }, - { - Artist: &mellodoot, - Role: "artwork", - }, - }, - }, -} - func GetRelease(id string) (MusicRelease, bool) { for _, album := range placeholders { if album.Id == id { diff --git a/api/v1/music/music_placeholders.go b/api/v1/music/music_placeholders.go new file mode 100644 index 0000000..96b1f61 --- /dev/null +++ b/api/v1/music/music_placeholders.go @@ -0,0 +1,161 @@ +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", + }, + }, + }, +} + diff --git a/api/v1/music/music_types.go b/api/v1/music/music_types.go index 046143f..72677d9 100644 --- a/api/v1/music/music_types.go +++ b/api/v1/music/music_types.go @@ -24,7 +24,7 @@ type ( Links []MusicLink Description string Credits []MusicCredit - Lyrics string + Tracks []MusicTrack } MusicLink struct { @@ -37,20 +37,26 @@ type ( Role string Meta bool // for "meta" contributors (i.e. not credited for the musical work, but other related assets) } + + MusicTrack struct { + Number int + Title string + Description string + Lyrics string + PreviewUrl string + } ) -func (album MusicRelease) GetUniqueArtists() []Artist { - if len(album.Credits) == 1 { - return []Artist{*album.Credits[0].Artist} - } +func (release MusicRelease) GetUniqueArtists(include_meta bool) []*Artist { + res := []*Artist{} + for _, credit := range release.Credits { + if !include_meta && credit.Meta { + continue + } - // create a map of artists to prevent duplicates - res := []Artist{} - for _, credit := range album.Credits { - artist := *credit.Artist exists := false - for _, c := range res { - if c == *credit.Artist { + for _, a := range res { + if a == credit.Artist { exists = true break } @@ -58,48 +64,16 @@ func (album MusicRelease) GetUniqueArtists() []Artist { if exists { continue } - res = append(res, artist) + + res = append(res, credit.Artist) } // now create the actual array to send return res } -func (album MusicRelease) GetUniqueNonMetaArtists() []Artist { - if len(album.Credits) == 1 { - return []Artist{*album.Credits[0].Artist} - } - - // create a map of artists to prevent duplicates - res := []Artist{} - for _, credit := range album.Credits { - if credit.Meta { - continue - } - artist := *credit.Artist - exists := false - for _, c := range res { - if c == *credit.Artist { - exists = true - break - } - } - if exists { - continue - } - res = append(res, artist) - } - - // now create the actual array to send - return res -} - -func (album MusicRelease) GetUniqueArtistNames() []string { - if len(album.Credits) == 1 { - return []string{album.Credits[0].Artist.Name} - } - - artists := album.GetUniqueArtists() +func (release MusicRelease) GetUniqueArtistNames(include_meta bool) []string { + artists := release.GetUniqueArtists(include_meta) names := []string{} for _, artist := range artists { names = append(names, artist.Name) @@ -108,22 +82,8 @@ func (album MusicRelease) GetUniqueArtistNames() []string { return names } -func (album MusicRelease) GetUniqueNonMetaArtistNames() []string { - if len(album.Credits) == 1 { - return []string{album.Credits[0].Artist.Name} - } - - artists := album.GetUniqueNonMetaArtists() - names := []string{} - for _, artist := range artists { - names = append(names, artist.Name) - } - - return names -} - -func (album MusicRelease) PrintPrimaryArtists() string { - names := album.GetUniqueNonMetaArtistNames() +func (album MusicRelease) PrintPrimaryArtists(include_meta bool) string { + names := album.GetUniqueArtistNames(include_meta) if len(names) == 1 { return names[0] } @@ -132,8 +92,8 @@ func (album MusicRelease) PrintPrimaryArtists() string { return res } -func (album MusicRelease) PrintCommaPrimaryArtists() string { - names := album.GetUniqueNonMetaArtistNames() +func (album MusicRelease) PrintCommaPrimaryArtists(include_meta bool) string { + names := album.GetUniqueArtistNames(include_meta) if len(names) == 1 { return names[0] } @@ -167,6 +127,10 @@ func (link MusicLink) NormaliseName() string { return strings.ToLower(re.ReplaceAllString(link.Name, "")) } +func (release MusicRelease) IsSingle() bool { + return len(release.Tracks) == 1; +} + func (credit MusicCredit) ResolveArtist() Artist { return *credit.Artist } diff --git a/db.go b/db.go index 8777aaf..5ae0e43 100644 --- a/db.go +++ b/db.go @@ -25,24 +25,32 @@ CREATE TABLE IF NOT EXISTS musicreleases ( release_date DATE NOT NULL, artwork TEXT, buyname TEXT, - buylink TEXT, - description TEXT, - lyrics TEXT + buylink TEXT ); CREATE TABLE IF NOT EXISTS musiclinks ( - album VARCHAR(64) REFERENCES musicreleases(id) ON DELETE CASCADE ON UPDATE CASCADE, + release VARCHAR(64) REFERENCES musicreleases(id) ON DELETE CASCADE ON UPDATE CASCADE, name TEXT, url TEXT, - CONSTRAINT musiclinks_pk PRIMARY KEY (album, name) + CONSTRAINT musiclinks_pk PRIMARY KEY (release, name) ); CREATE TABLE IF NOT EXISTS musiccredits ( - album VARCHAR(64) REFERENCES musicreleases(ID) ON DELETE CASCADE, + release VARCHAR(64) REFERENCES musicreleases(ID) ON DELETE CASCADE, artist TEXT REFERENCES artists(id) ON DELETE CASCADE, role TEXT, meta BOOLEAN, - constraint musiccredits_pk PRIMARY KEY (album, artist, role) + constraint musiccredits_pk PRIMARY KEY (release, artist) +); + +CREATE TABLE IF NOT EXISTS musictracks ( + release VARCHAR(64) REFERENCES musicreleases(ID) ON DELETE CASCADE, + number INT NOT NULL, + title TEXT NOT NULL, + description TEXT, + lyrics TEXT, + preview_url TEXT, + CONSTRAINT musictracks_pk PRIMARY KEY (release, number) );` func PushArtist(db *sqlx.DB, artist music.Artist) { @@ -61,18 +69,23 @@ func PushRelease(db *sqlx.DB, release music.MusicRelease) { fmt.Printf("syncing release [%s] to database...", release.Id) tx := db.MustBegin() - 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", - &release.Id, &release.Title, release.ReleaseDate.Format("2-Jan-2006"), &release.Artwork, &release.Buyname, &release.Buylink, &release.Description, &release.Lyrics) + tx.MustExec("INSERT INTO musicreleases (id, title, type, release_date, artwork, buyname, buylink) VALUES ($1, $2, $3, $4, $5, $6, $7) "+ + "ON CONFLICT (id) DO UPDATE SET title=$2, type=$3, release_date=$4, artwork=$5, buyname=$6, buylink=$7", + &release.Id, &release.Title, &release.Type, release.ReleaseDate.Format("2-Jan-2006"), &release.Artwork, &release.Buyname, &release.Buylink) 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", + tx.MustExec("INSERT INTO musiclinks (release, name, url) VALUES ($1, $2, $3) ON CONFLICT (release, name) DO UPDATE SET url=$3", &release.Id, &link.Name, &link.Url) } for _, credit := range release.Credits { - tx.MustExec("INSERT INTO musiccredits (album, artist, role, meta) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING", + tx.MustExec("INSERT INTO musiccredits (release, artist, role, meta) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING", &release.Id, &credit.Artist.Id, &credit.Role, &credit.Meta) } + for _, track := range release.Tracks { + tx.MustExec("INSERT INTO musictracks (release, number, title, description, lyrics, preview_url) VALUES ($1, $2, $3, $4, $5, $6) "+ + "ON CONFLICT (release, number) DO UPDATE SET title=$3, description=$4, lyrics=$5, preview_url=$6", + &release.Id, &track.Number, &track.Title, &track.Description, &track.Lyrics, &track.PreviewUrl) + } tx.Commit() diff --git a/public/style/main.css b/public/style/main.css index 52093bd..625d15c 100644 --- a/public/style/main.css +++ b/public/style/main.css @@ -34,6 +34,27 @@ a:hover { text-decoration: underline; } +a.link-button { + padding: .3em .5em; + border: 1px solid var(--links); + color: var(--links); + border-radius: 2px; + background-color: transparent; + transition-property: color, border-color, background-color; + transition-duration: .2s; + animation-delay: 0s; + animation: list-item-fadein .2s forwards; + opacity: 0; +} + +a.link-button:hover { + color: #eee; + border-color: #eee; + background-color: var(--links) !important; + text-decoration: none; + box-shadow: 0 0 1em var(--links); +} + small { font-size: 1em; color: #aaa; diff --git a/public/style/music-gateway.css b/public/style/music-gateway.css index bfed501..5725fa8 100644 --- a/public/style/music-gateway.css +++ b/public/style/music-gateway.css @@ -358,6 +358,33 @@ ul#links a:hover { font-size: 1.2em; } +#share { + margin: 0; + display: inline-block; + line-height: 1em; + text-shadow: 0 .05em 2px #0004; + cursor: pointer; + opacity: .5; + transition: opacity .1s linear; +} + +#share:hover { + opacity: 1; +} + +#share.active { + animation: share-click .5s forwards +} + +#share.active::after { + content: "✓"; + position: relative; + left: .2em; + font-size: 1.2em; + line-height: 1em; + animation: share-after 2s cubic-bezier(.5,0,1,.5) forwards +} + div#extras ul { height: 100%; display: flex; @@ -388,11 +415,6 @@ div#extras ul li a.active { color: #eee; } -a.scrollback { - color: #888; - font-style: italic; -} - #credits ul { list-style: "> "; } @@ -401,85 +423,30 @@ a.scrollback { margin-bottom: 1rem; } -#share { - margin: 0; - display: inline-block; - line-height: 1em; - text-shadow: 0 .05em 2px #0004; +#tracks ul { + padding: 0; + list-style: none; +} + +#tracks ul li { + margin-bottom: .5rem; + padding: 1rem; + background-color: #0008; cursor: pointer; - opacity: .5; - transition: opacity .1s linear; + transition: background-color .1s linear; } -#share:hover { - opacity: 1; +#tracks ul li:hover { + background-color: #2228; } -#share.active { - animation: share-click .5s forwards +#tracks ul li:active { + background-color: #4448; } -#share.active::after { - content: "✓"; - position: relative; - left: .2em; - font-size: 1.2em; - line-height: 1em; - animation: share-after 2s cubic-bezier(.5,0,1,.5) forwards -} - -#tracks { - flex-basis: 100%; - max-height: 10rem; - margin: auto 8rem; - display: flex; - flex-wrap: wrap; - gap: 0 2rem; - overflow-y: auto; - scrollbar-color: #fff transparent; - scrollbar-width: thin -} - -#tracks .track-preview { - width: 100%; - height: 2.5rem; - display: flex; - flex-direction: row; - border-bottom: 1px solid #fff2; - border-radius: 4px; - user-select: none; - transition: background-color .2s,color .2s -} - -#tracks .track-preview: last-of-type { - border-bottom: none -} - -.track-preview:hover { - background-color: #0002 -} - -.track-preview.playing { - color: #111; - background-color: #fff -} - -.track-preview i { - width: .7em; - margin: auto .8em; - pointer-events: none -} - -.track-preview p { - margin: auto 0; - display: inline-block; - line-height: 2em; - font-size: 1em; - pointer-events: none -} - -.track-preview audio { - width: 100% +#tracks ul li.active { + color: #000; + background-color: var(--primary); } footer { @@ -510,28 +477,6 @@ footer a:hover { text-decoration: underline } -/* -@media only screen and (min-width: 1105px) { - div#music-container:not(:has(> div#info #credits:target)):not(:has(> div#info #lyrics:target)) { - div#extras ul li:first-of-type a { - color: #eee; - } - } - - div#music-container:has(> div#info #credits:target) { - div#extras ul li a[href="#credits"] { - color: #eee; - } - } - - div#music-container:has(> div#info #lyrics:target) { - div#extras ul li a[href="#lyrics"] { - color: #eee; - } - } -} -*/ - @media only screen and (max-width: 1105px) { main { min-height: calc(100vh - 4rem); @@ -619,10 +564,6 @@ footer a:hover { transform: translate(calc(-50% - .6em),1.5em); } - #tracks { - margin: 0; - } - footer { height: 4rem; font-size: .8rem; diff --git a/public/style/music.css b/public/style/music.css index 91d30ba..1114468 100644 --- a/public/style/music.css +++ b/public/style/music.css @@ -7,6 +7,10 @@ main { padding-top: 4rem; } +main nav { + margin: -1rem .5rem 1rem .5rem; +} + div.music { margin-bottom: 1rem; padding: 1.5rem; @@ -93,6 +97,7 @@ h3.music-type-upcoming { list-style: none; } +/* .music-links li a { padding: .2em .5em; border: 1px solid #65b4fd; @@ -106,13 +111,13 @@ h3.music-type-upcoming { opacity: 0; } - .music-links li a:hover { color: #eee; border-color: #eee; background-color: var(--links) !important; text-decoration: none; } +*/ h2.question { margin: 1rem 0; diff --git a/views/music-gateway.html b/views/music-gateway.html index 76281bf..131d959 100644 --- a/views/music-gateway.html +++ b/views/music-gateway.html @@ -1,17 +1,17 @@ {{define "head"}} -{{.PrintPrimaryArtists}} - {{.Title}} +{{.PrintPrimaryArtists false}} - {{.Title}} - - - + + + - - + + @@ -19,7 +19,7 @@ - + @@ -54,7 +54,7 @@

{{.Title}}

{{.GetReleaseYear}} -

{{.PrintPrimaryArtists}}

+

{{.PrintPrimaryArtists false}}

{{.ResolveType}}