From 89087790dff0211a65e9a7f5120c3aea073a983a Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Sun, 15 Sep 2024 04:35:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E8=AF=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 65 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/main.go b/main.go index 90b8e71..6ea43da 100644 --- a/main.go +++ b/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) {