添加重试功能

pull/33/head
itouakirai 2 months ago committed by GitHub
parent d161fd30ec
commit 89087790df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 65
      main.go

@ -1594,6 +1594,12 @@ func rip(albumId string, token string, storefront string, userToken string) erro
}
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
trackNum++
if isInArray(okDict[albumId], trackNum) {
//fmt.Println("已完成直接跳过.\n")
trackTotalnum += 1
oktrackNum += 1
continue
}
if isInArray(selected, trackNum) {
trackTotalnum += 1
fmt.Printf("Track %d of %d:\n", trackNum, trackTotal)
@ -1875,36 +1881,45 @@ func main() {
os.Args = newArgs
}
albumTotal := len(os.Args)
for albumNum, url := range os.Args {
fmt.Printf("Album %d of %d:\n", albumNum+1, albumTotal)
var storefront, albumId string
if strings.Contains(url, ".txt") {
txtpath = url
fileName := filepath.Base(url)
parts := strings.SplitN(fileName, "_", 3)
storefront = parts[0]
albumId = parts[1]
} else {
if strings.Contains(url, "/playlist/") {
storefront, albumId = checkUrlPlaylist(url)
txtpath = ""
for {
for albumNum, url := range os.Args {
fmt.Printf("Album %d of %d:\n", albumNum+1, albumTotal)
var storefront, albumId string
if strings.Contains(url, ".txt") {
txtpath = url
fileName := filepath.Base(url)
parts := strings.SplitN(fileName, "_", 3)
storefront = parts[0]
albumId = parts[1]
} else {
storefront, albumId = checkUrl(url)
txtpath = ""
if strings.Contains(url, "/playlist/") {
storefront, albumId = checkUrlPlaylist(url)
txtpath = ""
} else {
storefront, albumId = checkUrl(url)
txtpath = ""
}
}
if albumId == "" {
fmt.Printf("Invalid URL: %s\n", url)
continue
}
err = rip(albumId, token, storefront, config.MediaUserToken)
if err != nil {
fmt.Println("Album failed.")
fmt.Println(err)
}
}
if albumId == "" {
fmt.Printf("Invalid URL: %s\n", url)
continue
}
err = rip(albumId, token, storefront, config.MediaUserToken)
if err != nil {
fmt.Println("Album failed.")
fmt.Println(err)
fmt.Printf("======= Completed %d/%d ###### %d errors!! =======\n", oktrackNum, trackTotalnum, trackTotalnum-oktrackNum)
if trackTotalnum-oktrackNum == 0 {
break
}
fmt.Println("Error detected, press Enter to try again...")
fmt.Scanln()
fmt.Println("Start trying again...")
oktrackNum = 0
trackTotalnum = 0
}
fmt.Printf("======= Completed %d/%d ###### %d errors!! =======\n", oktrackNum, trackTotalnum, trackTotalnum-oktrackNum)
}
func conventSyllableTTMLToLRC(ttml string) (string, error) {

Loading…
Cancel
Save