Merge pull request #4 from WorldObservationLog/main
fix: panic when the resp data of lyrics is empty
This commit is contained in:
commit
e0520a9400
4
main.go
4
main.go
@ -1013,7 +1013,11 @@ func getSongLyrics(songId string, storefront string, token string, userToken str
|
|||||||
defer do.Body.Close()
|
defer do.Body.Close()
|
||||||
obj := new(SongLyrics)
|
obj := new(SongLyrics)
|
||||||
err = json.NewDecoder(do.Body).Decode(&obj)
|
err = json.NewDecoder(do.Body).Decode(&obj)
|
||||||
|
if obj.Data != nil {
|
||||||
return obj.Data[0].Attributes.Ttml, nil
|
return obj.Data[0].Attributes.Ttml, nil
|
||||||
|
} else {
|
||||||
|
return "", errors.New("failed to get lyrics")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeCover(sanAlbumFolder, url string) error {
|
func writeCover(sanAlbumFolder, url string) error {
|
||||||
|
@ -1019,7 +1019,11 @@ func getSongLyrics(songId string, storefront string, token string, userToken str
|
|||||||
defer do.Body.Close()
|
defer do.Body.Close()
|
||||||
obj := new(SongLyrics)
|
obj := new(SongLyrics)
|
||||||
err = json.NewDecoder(do.Body).Decode(&obj)
|
err = json.NewDecoder(do.Body).Decode(&obj)
|
||||||
|
if obj.Data != nil {
|
||||||
return obj.Data[0].Attributes.Ttml, nil
|
return obj.Data[0].Attributes.Ttml, nil
|
||||||
|
} else {
|
||||||
|
return "", errors.New("failed to get lyrics")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeCover(sanAlbumFolder, url string) error {
|
func writeCover(sanAlbumFolder, url string) error {
|
||||||
|
@ -1012,7 +1012,11 @@ func getSongLyrics(songId string, storefront string, token string, userToken str
|
|||||||
defer do.Body.Close()
|
defer do.Body.Close()
|
||||||
obj := new(SongLyrics)
|
obj := new(SongLyrics)
|
||||||
err = json.NewDecoder(do.Body).Decode(&obj)
|
err = json.NewDecoder(do.Body).Decode(&obj)
|
||||||
|
if obj.Data != nil {
|
||||||
return obj.Data[0].Attributes.Ttml, nil
|
return obj.Data[0].Attributes.Ttml, nil
|
||||||
|
} else {
|
||||||
|
return "", errors.New("failed to get lyrics")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeCover(sanAlbumFolder, url string) error {
|
func writeCover(sanAlbumFolder, url string) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user