Compare commits

...

4 Commits

Author SHA1 Message Date
ZHAAREY
a086da99c0 Merge pull request #68 from MDSVJ/main
Enhanced LRC support by @AAGaming00
2025-06-24 19:19:44 +08:00
ZHAAREY
2ee7b50082 Merge pull request #69 from WorldObservationLog/main
fix: unable to collect information about albums with more than 300 tracks
2025-06-24 19:15:56 +08:00
世界观察日志
5d25210432 fix: unable to collect information about albums with more than 300 tracks 2025-06-24 18:43:41 +08:00
MDSVJ
6940c82d70 Enhanced LRC support by @AAGaming00 2025-06-15 23:46:26 -07:00
2 changed files with 1979 additions and 1976 deletions

View File

@@ -356,6 +356,7 @@ func getMeta(albumId string, token string, storefront string) (*structs.AutoGene
}
if strings.Contains(albumId, "pl.") {
obj.Data[0].Attributes.ArtistName = "Apple Music"
}
if len(obj.Data[0].Relationships.Tracks.Next) > 0 {
next = obj.Data[0].Relationships.Tracks.Next
for {
@@ -388,7 +389,6 @@ func getMeta(albumId string, token string, storefront string) (*structs.AutoGene
}
}
}
}
return obj, nil
}

View File

@@ -26,7 +26,6 @@ type SongLyrics struct {
} `json:"data"`
}
func Get(storefront, songId, lrcType, language, lrcFormat, token, mediaUserToken string) (string, error) {
if len(mediaUserToken) < 50 {
return "", errors.New("MediaUserToken not set")
@@ -166,7 +165,7 @@ func conventSyllableTTMLToLRC(ttml string) (string, error) {
return "", err
}
var lrcLines []string
parseTime := func(timeValue string) (string, error) {
parseTime := func(timeValue string, newLine bool) (string, error) {
var h, m, s, ms int
if strings.Contains(timeValue, ":") {
_, err = fmt.Sscanf(timeValue, "%d:%d:%d.%d", &h, &m, &s, &ms)
@@ -183,7 +182,11 @@ func conventSyllableTTMLToLRC(ttml string) (string, error) {
}
m += h * 60
ms = ms / 10
return fmt.Sprintf("[%02d:%02d.%02d]", m, s, ms), nil
if newLine {
return fmt.Sprintf("[%02d:%02d.%02d]<%02d:%02d.%02d>", m, s, ms, m, s, ms), nil
} else {
return fmt.Sprintf("<%02d:%02d.%02d>", m, s, ms), nil
}
}
divs := parsedTTML.FindElement("tt").FindElement("body").FindElements("div")
//get trans
@@ -217,11 +220,11 @@ func conventSyllableTTMLToLRC(ttml string) (string, error) {
if lyric.SelectAttr("begin") == nil {
continue
}
beginTime, err := parseTime(lyric.SelectAttr("begin").Value)
beginTime, err := parseTime(lyric.SelectAttr("begin").Value, i == 0)
if err != nil {
return "", err
}
endTime, err = parseTime(lyric.SelectAttr("end").Value)
endTime, err = parseTime(lyric.SelectAttr("end").Value, false)
if err != nil {
return "", err
}