commit
3743e8f2b6
@ -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
|
||||
6. Start the script as usual
|
||||
|
22
main.go
22
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1153,11 +1149,21 @@ 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
|
||||
}
|
||||
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
|
||||
|
@ -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)
|
||||
@ -1127,19 +1127,15 @@ 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 +1170,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),
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user