commit
24b9ef12b8
@ -1,8 +1,9 @@
|
|||||||
media-user-token: "your-media-user-token" #If you need to obtain the lyrics, need to change it
|
media-user-token: "your-media-user-token" #If you need to obtain the lyrics, need to change it
|
||||||
authorization-token: "your-authorization-token" #You don't need to change it; it can automatically obtain token
|
authorization-token: "your-authorization-token" #You don't need to change it; it can automatically obtain token
|
||||||
|
language: "" #supportedLanguage by each storefront --> https://gist.github.com/itouakirai/c8ba9df9dc65bd300094103b058731d0
|
||||||
lrc-type: "lyrics" #lyrics or syllable-lyrics
|
lrc-type: "lyrics" #lyrics or syllable-lyrics
|
||||||
lrc-format: "lrc" #lrc or ttml
|
lrc-format: "lrc" #lrc or ttml
|
||||||
embed-lrc: true
|
embed-lrc: true #Unable to embed ttml lyrics
|
||||||
save-lrc-file: false
|
save-lrc-file: false
|
||||||
save-artist-cover: false
|
save-artist-cover: false
|
||||||
save-animated-artwork: false # If enabled, requires ffmpeg
|
save-animated-artwork: false # If enabled, requires ffmpeg
|
||||||
|
14
main.go
14
main.go
@ -51,6 +51,7 @@ var (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
MediaUserToken string `yaml:"media-user-token"`
|
MediaUserToken string `yaml:"media-user-token"`
|
||||||
AuthorizationToken string `yaml:"authorization-token"`
|
AuthorizationToken string `yaml:"authorization-token"`
|
||||||
|
Language string `yaml:"language"`
|
||||||
SaveLrcFile bool `yaml:"save-lrc-file"`
|
SaveLrcFile bool `yaml:"save-lrc-file"`
|
||||||
LrcType string `yaml:"lrc-type"`
|
LrcType string `yaml:"lrc-type"`
|
||||||
LrcFormat string `yaml:"lrc-format"`
|
LrcFormat string `yaml:"lrc-format"`
|
||||||
@ -1119,6 +1120,8 @@ func getUrlArtistName(artistUrl string, token string) (string, error) {
|
|||||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
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("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("Origin", "https://music.apple.com")
|
req.Header.Set("Origin", "https://music.apple.com")
|
||||||
|
query := url.Values{}
|
||||||
|
query.Set("l", config.Language)
|
||||||
do, err := http.DefaultClient.Do(req)
|
do, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -1143,7 +1146,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", storefront, artistId, Num), nil)
|
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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1263,7 +1266,7 @@ func getMeta(albumId string, token string, storefront string) (*AutoGenerated, e
|
|||||||
query.Set("fields[albums:albums]", "artistName,artwork,name,releaseDate,url")
|
query.Set("fields[albums:albums]", "artistName,artwork,name,releaseDate,url")
|
||||||
query.Set("fields[record-labels]", "name")
|
query.Set("fields[record-labels]", "name")
|
||||||
query.Set("extend", "editorialVideo")
|
query.Set("extend", "editorialVideo")
|
||||||
// query.Set("l", "en-gb")
|
query.Set("l", config.Language)
|
||||||
req.URL.RawQuery = query.Encode()
|
req.URL.RawQuery = query.Encode()
|
||||||
do, err := http.DefaultClient.Do(req)
|
do, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1285,7 +1288,7 @@ func getMeta(albumId string, token string, storefront string) (*AutoGenerated, e
|
|||||||
for {
|
for {
|
||||||
page = page + 100
|
page = page + 100
|
||||||
pageStr := strconv.Itoa(page)
|
pageStr := strconv.Itoa(page)
|
||||||
req, err := http.NewRequest("GET", fmt.Sprintf("https://amp-api.music.apple.com/v1/catalog/%s/%s/%s/tracks?offset=%s", storefront, mtype, albumId, pageStr), nil)
|
req, err := http.NewRequest("GET", fmt.Sprintf("https://amp-api.music.apple.com/v1/catalog/%s/%s/%s/tracks?offset=%s&l=%s", storefront, mtype, albumId, pageStr, config.Language), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1726,9 +1729,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to write lyrics")
|
fmt.Printf("Failed to write lyrics")
|
||||||
}
|
}
|
||||||
if !config.EmbedLrc {
|
lrc = ""
|
||||||
lrc = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lrc, err = conventTTMLToLRC(ttml)
|
lrc, err = conventTTMLToLRC(ttml)
|
||||||
@ -2599,6 +2600,7 @@ func getInfoFromAdam(adamId string, token string, storefront string) (*SongData,
|
|||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
query.Set("extend", "extendedAssetUrls")
|
query.Set("extend", "extendedAssetUrls")
|
||||||
query.Set("include", "albums")
|
query.Set("include", "albums")
|
||||||
|
query.Set("l", config.Language)
|
||||||
request.URL.RawQuery = query.Encode()
|
request.URL.RawQuery = query.Encode()
|
||||||
|
|
||||||
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user