diff --git a/lyrics.go b/lyrics.go index aa943f0..0fdcb8c 100644 --- a/lyrics.go +++ b/lyrics.go @@ -11,12 +11,14 @@ import ( ) type song struct { - Artist string - Title string - Image string - Lyrics string - Credits map[string]string - About [2]string + Artist string + Title string + Image string + Lyrics string + Credits map[string]string + About [2]string + Album string + LinkToAlbum string } type songResponse struct { @@ -28,6 +30,10 @@ type songResponse struct { Description struct { Plain string } + Album struct { + Url string `json:"url"` + Name string `json:"name"` + } CustomPerformances []customPerformance `json:"custom_performances"` } } @@ -54,6 +60,7 @@ func (s *song) parseSongData(doc *goquery.Document) { attr, exists := doc.Find("meta[property='twitter:app:url:iphone']").Attr("content") if exists { songID := strings.Replace(attr, "genius://songs/", "", 1) + u := fmt.Sprintf("https://genius.com/api/songs/%s?text_format=plain", songID) res, err := sendRequest(u) @@ -77,6 +84,8 @@ func (s *song) parseSongData(doc *goquery.Document) { s.About[0] = songData.Description.Plain s.About[1] = truncateText(songData.Description.Plain) s.Credits = make(map[string]string) + s.Album = songData.Album.Name + s.LinkToAlbum = strings.Replace(songData.Album.Url, "https://genius.com", "", -1) for _, perf := range songData.CustomPerformances { var artists []string diff --git a/static/style.css b/static/style.css index e166a83..1ced795 100644 --- a/static/style.css +++ b/static/style.css @@ -101,7 +101,7 @@ a { font-weight: 500; } -#metadata > img { +#album-artwork { width: 20rem; border-radius: 3px; box-shadow: 0 1px 1px #ddd; diff --git a/views/album.tmpl b/views/album.tmpl index cb2a2c6..db35d77 100644 --- a/views/album.tmpl +++ b/views/album.tmpl @@ -11,7 +11,7 @@ {{template "navbar"}}