mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-26 13:49:21 +08:00
handle errors of lyric embed
This commit is contained in:
parent
be2d4f5ef3
commit
e4deba451e
@ -1,6 +1,7 @@
|
||||
package lyric
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@ -29,8 +30,13 @@ func GetLyric(url string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return lyric, nil
|
||||
if lyric == "" {
|
||||
return "", fmt.Errorf("no lyric available")
|
||||
}
|
||||
if looksLikeLRC(lyric) {
|
||||
return lyric, nil
|
||||
}
|
||||
return "", fmt.Errorf("lyric not compatible")
|
||||
}
|
||||
|
||||
// GetLyricOptions queries available song lyrics. It returns map of title and
|
||||
|
@ -98,5 +98,8 @@ func GetLyricChinese(lyricID string, serviceProvider string) (string, error) {
|
||||
// io.WriteString(file, lyric)
|
||||
// file.Close()
|
||||
// }
|
||||
return lyric, nil
|
||||
if looksLikeLRC(lyric) {
|
||||
return lyric, nil
|
||||
}
|
||||
return "", fmt.Errorf("lyric not compatible")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user