mirror of
https://github.com/zhaarey/apple-music-downloader.git
synced 2025-10-23 15:11:05 +00:00
fix: unable to collect information about albums with more than 300 tracks
This commit is contained in:
60
main.go
60
main.go
@@ -356,36 +356,36 @@ func getMeta(albumId string, token string, storefront string) (*structs.AutoGene
|
|||||||
}
|
}
|
||||||
if strings.Contains(albumId, "pl.") {
|
if strings.Contains(albumId, "pl.") {
|
||||||
obj.Data[0].Attributes.ArtistName = "Apple Music"
|
obj.Data[0].Attributes.ArtistName = "Apple Music"
|
||||||
if len(obj.Data[0].Relationships.Tracks.Next) > 0 {
|
}
|
||||||
next = obj.Data[0].Relationships.Tracks.Next
|
if len(obj.Data[0].Relationships.Tracks.Next) > 0 {
|
||||||
for {
|
next = obj.Data[0].Relationships.Tracks.Next
|
||||||
req, err := http.NewRequest("GET", fmt.Sprintf("https://amp-api.music.apple.com/%s&l=%s&include=albums", next, Config.Language), nil)
|
for {
|
||||||
if err != nil {
|
req, err := http.NewRequest("GET", fmt.Sprintf("https://amp-api.music.apple.com/%s&l=%s&include=albums", next, Config.Language), nil)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
}
|
||||||
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
|
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||||
req.Header.Set("Origin", "https://music.apple.com")
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
|
||||||
do, err := http.DefaultClient.Do(req)
|
req.Header.Set("Origin", "https://music.apple.com")
|
||||||
if err != nil {
|
do, err := http.DefaultClient.Do(req)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
defer do.Body.Close()
|
}
|
||||||
if do.StatusCode != http.StatusOK {
|
defer do.Body.Close()
|
||||||
return nil, errors.New(do.Status)
|
if do.StatusCode != http.StatusOK {
|
||||||
}
|
return nil, errors.New(do.Status)
|
||||||
obj2 := new(structs.AutoGeneratedTrack)
|
}
|
||||||
err = json.NewDecoder(do.Body).Decode(&obj2)
|
obj2 := new(structs.AutoGeneratedTrack)
|
||||||
if err != nil {
|
err = json.NewDecoder(do.Body).Decode(&obj2)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
for _, value := range obj2.Data {
|
}
|
||||||
obj.Data[0].Relationships.Tracks.Data = append(obj.Data[0].Relationships.Tracks.Data, value)
|
for _, value := range obj2.Data {
|
||||||
}
|
obj.Data[0].Relationships.Tracks.Data = append(obj.Data[0].Relationships.Tracks.Data, value)
|
||||||
next = obj2.Next
|
}
|
||||||
if len(next) == 0 {
|
next = obj2.Next
|
||||||
break
|
if len(next) == 0 {
|
||||||
}
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user