feat: show writers and producers in credits
This commit is contained in:
parent
119843dad7
commit
0441b0112c
@ -38,6 +38,12 @@ type songResponse struct {
|
|||||||
Image string `json:"cover_art_url"`
|
Image string `json:"cover_art_url"`
|
||||||
}
|
}
|
||||||
CustomPerformances []customPerformance `json:"custom_performances"`
|
CustomPerformances []customPerformance `json:"custom_performances"`
|
||||||
|
WriterArtists []struct {
|
||||||
|
Name string
|
||||||
|
} `json:"writer_artists"`
|
||||||
|
ProducerArtists []struct {
|
||||||
|
Name string
|
||||||
|
} `json:"producer_artists"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,18 +105,26 @@ func (s *Song) parseSongData(doc *goquery.Document) error {
|
|||||||
s.Album.URL = strings.Replace(songData.Album.URL, "https://genius.com", "", -1)
|
s.Album.URL = strings.Replace(songData.Album.URL, "https://genius.com", "", -1)
|
||||||
s.Album.Image = ExtractImageURL(songData.Album.Image)
|
s.Album.Image = ExtractImageURL(songData.Album.Image)
|
||||||
|
|
||||||
|
s.Credits["Writers"] = joinNames(songData.WriterArtists)
|
||||||
|
s.Credits["Producers"] = joinNames(songData.ProducerArtists)
|
||||||
for _, perf := range songData.CustomPerformances {
|
for _, perf := range songData.CustomPerformances {
|
||||||
var artists []string
|
s.Credits[perf.Label] = joinNames(perf.Artists)
|
||||||
for _, artist := range perf.Artists {
|
|
||||||
artists = append(artists, artist.Name)
|
|
||||||
}
|
|
||||||
s.Credits[perf.Label] = strings.Join(artists, ", ")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func joinNames(data []struct {
|
||||||
|
Name string
|
||||||
|
}) string {
|
||||||
|
var names []string
|
||||||
|
for _, hasName := range data {
|
||||||
|
names = append(names, hasName.Name)
|
||||||
|
}
|
||||||
|
return strings.Join(names, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
func truncateText(text string) string {
|
func truncateText(text string) string {
|
||||||
textArr := strings.Split(text, "")
|
textArr := strings.Split(text, "")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user