From 05f976a4e892092eb8076bbd52d8930ca0133a49 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Sat, 28 Sep 2024 04:00:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BC=BA=E5=88=B6ttml=E6=AD=8C=E8=AF=8D?= =?UTF-8?q?=E4=B8=8D=E5=86=85=E5=B5=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/main.go b/main.go index 0440692..05de5ed 100644 --- a/main.go +++ b/main.go @@ -1726,9 +1726,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro if err != nil { fmt.Printf("Failed to write lyrics") } - if !config.EmbedLrc { - lrc = "" - } + lrc = "" } } else { lrc, err = conventTTMLToLRC(ttml) From 455a13b59a7244598c76490998de741eb9738a09 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:12:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=85=83=E6=95=B0=E6=8D=AE=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 05de5ed..9b9ea4e 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,7 @@ var ( type Config struct { MediaUserToken string `yaml:"media-user-token"` AuthorizationToken string `yaml:"authorization-token"` + Language string `yaml:"language"` SaveLrcFile bool `yaml:"save-lrc-file"` LrcType string `yaml:"lrc-type"` 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("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") + query := url.Values{} + query.Set("l", config.Language) do, err := http.DefaultClient.Do(req) if err != nil { return "", err @@ -1143,7 +1146,7 @@ func checkArtist(artistUrl string, token string) ([]string, error) { var urls []string var options []string 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 { 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[record-labels]", "name") query.Set("extend", "editorialVideo") - // query.Set("l", "en-gb") + query.Set("l", config.Language) req.URL.RawQuery = query.Encode() do, err := http.DefaultClient.Do(req) if err != nil { @@ -1285,7 +1288,7 @@ func getMeta(albumId string, token string, storefront string) (*AutoGenerated, e for { page = page + 100 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 { return nil, err } @@ -2597,6 +2600,7 @@ func getInfoFromAdam(adamId string, token string, storefront string) (*SongData, query := url.Values{} query.Set("extend", "extendedAssetUrls") query.Set("include", "albums") + query.Set("l", config.Language) request.URL.RawQuery = query.Encode() request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) From 370f71cb218e026f07528a4e24b21372a0f2779d Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:38:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=85=83=E6=95=B0=E6=8D=AE=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 5391e69..ea0fc37 100644 --- a/config.yaml +++ b/config.yaml @@ -1,8 +1,9 @@ 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 +language: "" #supportedLanguage by each storefront --> https://gist.github.com/itouakirai/c8ba9df9dc65bd300094103b058731d0 lrc-type: "lyrics" #lyrics or syllable-lyrics lrc-format: "lrc" #lrc or ttml -embed-lrc: true +embed-lrc: true #Unable to embed ttml lyrics save-lrc-file: false save-artist-cover: false save-animated-artwork: false # If enabled, requires ffmpeg