From a73b553b5c4b235ffb4916aa928979e49e0a2e51 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:48:08 +0800 Subject: [PATCH 1/9] Update main.go fix --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 5bb1e8b..2c5c1d4 100644 --- a/main.go +++ b/main.go @@ -1153,7 +1153,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro if !samplesOk { continue } - // err = decryptSong(info, keys, meta, trackPath, trackNum, trackTotal) + err = decryptSong(info, keys, meta, trackPath, trackNum, trackTotal) if err != nil { fmt.Println("Failed to decrypt track.\n", err) continue From 67e7aad2ddc078f3b538734da759bfb86befd858 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 05:10:30 +0800 Subject: [PATCH 2/9] Update main_atmos.go --- main_atmos.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main_atmos.go b/main_atmos.go index 09229bf..e287523 100644 --- a/main_atmos.go +++ b/main_atmos.go @@ -1127,19 +1127,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro oktrackNum += 1 continue } + var lrc string = "" if userToken != "" { ttml, err := getSongLyrics(track.ID, storefront, token, userToken) if err != nil { fmt.Println("Failed to get lyrics") } else { - lrc, err := conventTTMLToLRC(ttml) + lrc, err = conventTTMLToLRC(ttml) if err != nil { fmt.Printf("Failed to parse lyrics: %s \n", err) - } else { - err := writeLyrics(sanAlbumFolder, lrcFilename, lrc) - if err != nil { - fmt.Printf("Failed to write lyrics") - } + } } } } @@ -1174,6 +1171,9 @@ func rip(albumId string, token string, storefront string, userToken string) erro index := trackNum - 1 tags := []string{ "tool=", + fmt.Sprintf("lyrics=%s", lrc), + fmt.Sprintf("cover=%s/cover.jpg", sanAlbumFolder), + fmt.Sprintf("album=%s", meta.Data[0].Attributes.Name), fmt.Sprintf("title=%s", meta.Data[0].Relationships.Tracks.Data[index].Attributes.Name), fmt.Sprintf("album=%s", meta.Data[0].Attributes.Name), fmt.Sprintf("artist=%s", meta.Data[0].Relationships.Tracks.Data[index].Attributes.ArtistName), From dc130fbf1e8033fa358d67d86c4ae522fb2a85ef Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 05:43:19 +0800 Subject: [PATCH 3/9] Update add Embed cover and lrc --- main.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 2c5c1d4..864a392 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( "net/http" "net/url" "os" + "os/exec" "path/filepath" "regexp" "sort" @@ -1103,21 +1104,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro continue } filename := fmt.Sprintf("%02d. %s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) - lrcFilename := fmt.Sprintf("%02d. %s.lrc", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) trackPath := filepath.Join(sanAlbumFolder, filename) + var lrc string = "" if userToken != "" { ttml, err := getSongLyrics(track.ID, storefront, token, userToken) if err != nil { fmt.Println("Failed to get lyrics") } else { - lrc, err := conventTTMLToLRC(ttml) + lrc, err = conventTTMLToLRC(ttml) if err != nil { fmt.Printf("Failed to parse lyrics: %s \n", err) - } else { - err := writeLyrics(sanAlbumFolder, lrcFilename, lrc) - if err != nil { - fmt.Printf("Failed to write lyrics") - } } } } @@ -1158,6 +1154,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro fmt.Println("Failed to decrypt track.\n", err) continue } + tags := []string{ + fmt.Sprintf("lyrics=%s", lrc), + fmt.Sprintf("cover=%s/cover.jpg", sanAlbumFolder), + } + tagsString := strings.Join(tags, ":") + cmd := exec.Command("MP4Box","-itags", tagsString, trackPath) + if err := cmd.Run(); err != nil { + fmt.Printf("Embed failed: %v\n", err) + continue + } oktrackNum += 1 } return err From dcef5022b671e5d8f6bca34a7a96907bbb25ee40 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 05:48:51 +0800 Subject: [PATCH 4/9] Update main_select.go --- main_select.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/main_select.go b/main_select.go index edb9c2d..adcb048 100644 --- a/main_select.go +++ b/main_select.go @@ -15,6 +15,7 @@ import ( "net/http" "net/url" "os" + "os/exec" "path/filepath" "regexp" "sort" @@ -1139,21 +1140,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro continue } filename := fmt.Sprintf("%02d. %s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) - lrcFilename := fmt.Sprintf("%02d. %s.lrc", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) trackPath := filepath.Join(sanAlbumFolder, filename) + var lrc string = "" if userToken != "" { ttml, err := getSongLyrics(track.ID, storefront, token, userToken) if err != nil { fmt.Println("Failed to get lyrics") } else { - lrc, err := conventTTMLToLRC(ttml) + lrc, err = conventTTMLToLRC(ttml) if err != nil { fmt.Printf("Failed to parse lyrics: %s \n", err) - } else { - err := writeLyrics(sanAlbumFolder, lrcFilename, lrc) - if err != nil { - fmt.Printf("Failed to write lyrics") - } } } } @@ -1193,6 +1189,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro fmt.Println("Failed to decrypt track.\n", err) continue } + tags := []string{ + fmt.Sprintf("lyrics=%s", lrc), + fmt.Sprintf("cover=%s/cover.jpg", sanAlbumFolder), + } + tagsString := strings.Join(tags, ":") + cmd := exec.Command("MP4Box","-itags", tagsString, trackPath) + if err := cmd.Run(); err != nil { + fmt.Printf("Embed failed: %v\n", err) + continue + } } } return err From 5c738e51104a501ba67570e9d08a5b8d19344518 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 05:52:44 +0800 Subject: [PATCH 5/9] Update main_atmos.go --- main_atmos.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main_atmos.go b/main_atmos.go index e287523..650d6da 100644 --- a/main_atmos.go +++ b/main_atmos.go @@ -1137,7 +1137,6 @@ func rip(albumId string, token string, storefront string, userToken string) erro if err != nil { fmt.Printf("Failed to parse lyrics: %s \n", err) } - } } } trackUrl, keys, err := extractMedia(manifest.Attributes.ExtendedAssetUrls.EnhancedHls) From 8fac8a9114fdd93559c326bf68da75d495aab966 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 06:00:33 +0800 Subject: [PATCH 6/9] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b660f2a..6824319 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -### !!封装杜比全景声必须先安装[MP4Box](https://gpac.io/downloads/gpac-nightly-builds/),并确认[MP4Box](https://gpac.io/downloads/gpac-nightly-builds/)已正确添加到环境变量 +### !!必须先安装[MP4Box](https://gpac.io/downloads/gpac-nightly-builds/),并确认[MP4Box](https://gpac.io/downloads/gpac-nightly-builds/)已正确添加到环境变量 ### 添加功能 1. 调用外部MP4Box自动封装ec3为m4a 2. 更改目录结构为 歌手名\专辑名 ;Atmos下载文件则另外移动到AM-DL-Atmos downloads,并更改目录结构为 歌手名\专辑名 [Atmos] 3. 运行结束后显示总体完成情况 -4. 下载LRC歌词 +4. 自动内嵌LRC歌词(需要media-user-token)和封面 @@ -32,4 +32,4 @@ Original script by Sorrow. Modified by me to include some fixes and improvements 3. Find the cookie named `media-user-token` and copy its value 4. Create a file named `media-user-token.txt` in the project root directory 5. Paste the cookie value obtained in step 3 into the file and save it -6. Start the script as usual \ No newline at end of file +6. Start the script as usual From 9130d915ef10a2b6bf177651356329d2334d32e5 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 06:12:50 +0800 Subject: [PATCH 7/9] Update main_atmos.go --- main_atmos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main_atmos.go b/main_atmos.go index 650d6da..ba1a668 100644 --- a/main_atmos.go +++ b/main_atmos.go @@ -1111,7 +1111,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro } filename := fmt.Sprintf("%02d. %s.ec3", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) m4afilename := fmt.Sprintf("%02d. %s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) - lrcFilename := fmt.Sprintf("%02d. %s.lrc", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) + //lrcFilename := fmt.Sprintf("%02d. %s.lrc", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) trackPath := filepath.Join(sanAlbumFolder, filename) m4atrackPath := filepath.Join(sanAlbumFolder, m4afilename) exists, err := fileExists(trackPath) From ca03f873934e84c0dfffb92c5d5eb69cc285b253 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 06:34:28 +0800 Subject: [PATCH 8/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6824319..55b9ebf 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 1. 调用外部MP4Box自动封装ec3为m4a 2. 更改目录结构为 歌手名\专辑名 ;Atmos下载文件则另外移动到AM-DL-Atmos downloads,并更改目录结构为 歌手名\专辑名 [Atmos] 3. 运行结束后显示总体完成情况 -4. 自动内嵌LRC歌词(需要media-user-token)和封面 +4. 自动内嵌LRC歌词(需要media-user-token,获取方式看最后的说明)和封面 From 33f58898df48ceaa4b5f46a62e8323180cec971e Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 24 Apr 2024 06:35:34 +0800 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 55b9ebf..1ea3a56 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 1. 调用外部MP4Box自动封装ec3为m4a 2. 更改目录结构为 歌手名\专辑名 ;Atmos下载文件则另外移动到AM-DL-Atmos downloads,并更改目录结构为 歌手名\专辑名 [Atmos] 3. 运行结束后显示总体完成情况 -4. 自动内嵌LRC歌词(需要media-user-token,获取方式看最后的说明)和封面 +4. 自动内嵌封面和LRC歌词(需要media-user-token,获取方式看最后的说明)