refactor: remove redundant code

This commit is contained in:
rramiachraf 2024-06-11 21:02:58 +01:00
parent 3bf802c9c2
commit 41d13e1edb
4 changed files with 15 additions and 23 deletions

View file

@ -15,7 +15,7 @@ type Song struct {
Image string
Lyrics string
Credits map[string]string
About [2]string
About string
Album AlbumPreview
}
@ -94,8 +94,7 @@ func (s *Song) parseSongData(doc *goquery.Document) error {
s.Artist = songData.ArtistNames
s.Image = songData.Image
s.Title = songData.Title
s.About[0] = songData.Description.Plain
s.About[1] = truncateText(songData.Description.Plain)
s.About = songData.Description.Plain
s.Credits = make(map[string]string)
s.Album.Name = songData.Album.Name
s.Album.URL = strings.Replace(songData.Album.URL, "https://genius.com", "", -1)
@ -122,16 +121,6 @@ func joinNames(data []struct {
return strings.Join(names, ", ")
}
func truncateText(text string) string {
textArr := strings.Split(text, "")
if len(textArr) > 250 {
return strings.Join(textArr[0:250], "") + "..."
}
return text
}
func (s *Song) Parse(doc *goquery.Document) error {
if err := s.parseLyrics(doc); err != nil {
return err