feat: add link to song's album on lyrics page
This commit is contained in:
parent
273176a57c
commit
9c8ed042a5
@ -17,6 +17,8 @@ type song struct {
|
||||
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
|
||||
|
@ -101,7 +101,7 @@ a {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
#metadata > img {
|
||||
#album-artwork {
|
||||
width: 20rem;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 1px #ddd;
|
||||
|
@ -11,7 +11,7 @@
|
||||
{{template "navbar"}}
|
||||
<div id="container">
|
||||
<div id="metadata">
|
||||
<img src="{{extractURL .Image}}"/>
|
||||
<img id="album-artwork" src="{{extractURL .Image}}"/>
|
||||
<h2>{{.Artist}}</h2>
|
||||
<h1>{{.Name}}</h1>
|
||||
</div>
|
||||
|
@ -11,9 +11,10 @@
|
||||
{{template "navbar"}}
|
||||
<div id="container">
|
||||
<div id="metadata">
|
||||
<img src="{{extractURL .Image}}"/>
|
||||
<a href="{{.LinkToAlbum}}"><img id="album-artwork" src="{{extractURL .Image}}"/></a>
|
||||
<h2>{{.Artist}}</h2>
|
||||
<h1>{{.Title}}</h1>
|
||||
<a href="{{.LinkToAlbum}}"><h2>{{.Album}}</h2></a>
|
||||
</div>
|
||||
<div id="lyrics">{{.Lyrics}}</div>
|
||||
<div id="info">
|
||||
|
Loading…
x
Reference in New Issue
Block a user