add: artist mv dl

This commit is contained in:
itouakirai 2025-02-12 08:58:40 +08:00
parent 591049cedc
commit 8ce10e89cc

17
main.go
View File

@ -182,7 +182,7 @@ func getUrlArtistName(artistUrl string, token string) (string, string, error) {
return obj.Data[0].Attributes.Name, obj.Data[0].ID , nil return obj.Data[0].Attributes.Name, obj.Data[0].ID , nil
} }
func checkArtist(artistUrl string, token string) ([]string, error) { func checkArtist(artistUrl string, token string, relationship string) ([]string, error) {
storefront, artistId := checkUrlArtist(artistUrl) storefront, artistId := checkUrlArtist(artistUrl)
Num := 0 Num := 0
@ -190,7 +190,7 @@ func checkArtist(artistUrl string, token string) ([]string, error) {
var urls []string var urls []string
var options []string var options []string
for { for {
req, err := http.NewRequest("GET", fmt.Sprintf("https://amp-api.music.apple.com/v1/catalog/%s/artists/%s/albums?limit=100&offset=%d&l=%s", storefront, artistId, Num, Config.Language), nil) req, err := http.NewRequest("GET", fmt.Sprintf("https://amp-api.music.apple.com/v1/catalog/%s/artists/%s/%s?limit=100&offset=%d&l=%s", storefront, artistId, relationship, Num, Config.Language), nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -227,7 +227,7 @@ func checkArtist(artistUrl string, token string) ([]string, error) {
return urls, nil return urls, nil
} }
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
fmt.Println("Please select from the following options (multiple options separated by commas, ranges supported, or type 'all' to select all)") fmt.Println("Please select from the following " + relationship + " options (multiple options separated by commas, ranges supported, or type 'all' to select all)")
fmt.Print("Enter your choice: ") fmt.Print("Enter your choice: ")
input, _ := reader.ReadString('\n') input, _ := reader.ReadString('\n')
@ -1142,12 +1142,17 @@ func main() {
"{UrlArtistName}", LimitString(urlArtistName), "{UrlArtistName}", LimitString(urlArtistName),
"{ArtistId}", urlArtistID, "{ArtistId}", urlArtistID,
).Replace(Config.ArtistFolderFormat) ).Replace(Config.ArtistFolderFormat)
newArgs, err := checkArtist(os.Args[0], token) albumArgs, err := checkArtist(os.Args[0], token, "albums")
if err != nil { if err != nil {
fmt.Println("Failed to get artist.") fmt.Println("Failed to get artist albums.")
return return
} }
os.Args = newArgs mvArgs, err := checkArtist(os.Args[0], token, "music-videos")
if err != nil {
fmt.Println("Failed to get artist music-videos.")
return
}
os.Args = append(albumArgs, mvArgs...)
} }
albumTotal := len(os.Args) albumTotal := len(os.Args)
for { for {