mirror of
https://github.com/zhaarey/apple-music-downloader.git
synced 2025-10-23 15:11:05 +00:00
Add adm-aac mode
This commit is contained in:
12
README.md
12
README.md
@@ -22,20 +22,11 @@
|
||||
|
||||
- `alac (audio-alac-stereo)`
|
||||
- `ec3 (audio-atmos / audio-ec3)`
|
||||
|
||||
### Python项目
|
||||
|
||||
如需下载AAC推荐使用WorldObservationLog的[AppleMusicDecrypt](https://github.com/WorldObservationLog/AppleMusicDecrypt)
|
||||
|
||||
[AppleMusicDecrypt](https://github.com/WorldObservationLog/AppleMusicDecrypt)支持以下编码
|
||||
|
||||
- `alac (audio-alac-stereo)`
|
||||
- `ec3 (audio-atmos / audio-ec3)`
|
||||
- `ac3 (audio-ac3)`
|
||||
- `aac (audio-stereo)`
|
||||
- `aac-binaural (audio-stereo-binaural)`
|
||||
- `aac-downmix (audio-stereo-downmix)`
|
||||
|
||||
|
||||
# Apple Music ALAC / Dolby Atmos Downloader
|
||||
|
||||
Original script by Sorrow. Modified by me to include some fixes and improvements.
|
||||
@@ -63,6 +54,7 @@ Original script by Sorrow. Modified by me to include some fixes and improvements
|
||||
8. Start downloading singles: `go run main.go --select https://music.apple.com/us/album/whenever-you-need-somebody-2022-remaster/1624945511` input numbers separated by spaces.
|
||||
9. Start downloading some playlists: `go run main.go https://music.apple.com/us/playlist/taylor-swift-essentials/pl.3950454ced8c45a3b0cc693c2a7db97b` or `go run main.go https://music.apple.com/us/playlist/hi-res-lossless-24-bit-192khz/pl.u-MDAWvpjt38370N`.
|
||||
10. For dolby atmos: `go run main.go --atmos https://music.apple.com/us/album/1989-taylors-version-deluxe/1713845538`.
|
||||
11. For adm aac: `go run main.go --aac https://music.apple.com/us/album/1989-taylors-version-deluxe/1713845538`.
|
||||
|
||||
[中文教程-详见方法三](https://telegra.ph/Apple-Music-Alac高解析度无损音乐下载教程-04-02-2)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ get-m3u8-port: "127.0.0.1:20020"
|
||||
get-m3u8-from-device: true
|
||||
#set 'all' to retrieve all m3u8, and set 'hires' to only detect hires m3u8.
|
||||
get-m3u8-mode: hires # all hires
|
||||
aac-type: aac # aac aac-binaural aac-downmix
|
||||
alac-max: 192000 #192000 96000 48000 44100
|
||||
atmos-max: 2768 #2768 2448
|
||||
limit-max: 200
|
||||
|
||||
59
main.go
59
main.go
@@ -34,6 +34,7 @@ import (
|
||||
var (
|
||||
forbiddenNames = regexp.MustCompile(`[/\\<>:"|?*]`)
|
||||
dl_atmos bool
|
||||
dl_aac bool
|
||||
dl_select bool
|
||||
artist_select bool
|
||||
alac_max *int
|
||||
@@ -428,6 +429,8 @@ func rip(albumId string, token string, storefront string, userToken string) erro
|
||||
var Codec string
|
||||
if dl_atmos {
|
||||
Codec = "Atmos"
|
||||
} else if dl_aac {
|
||||
Codec = "AAC"
|
||||
} else {
|
||||
Codec = "ALAC"
|
||||
}
|
||||
@@ -859,6 +862,7 @@ func main() {
|
||||
}
|
||||
// Define command-line flags
|
||||
pflag.BoolVar(&dl_atmos, "atmos", false, "Enable atmos download mode")
|
||||
pflag.BoolVar(&dl_aac, "aac", false, "Enable adm-aac download mode")
|
||||
pflag.BoolVar(&dl_select, "select", false, "Enable selective download")
|
||||
pflag.BoolVar(&artist_select, "all-album", false, "Download all artist albums")
|
||||
alac_max = pflag.Int("alac-max", -1, "Specify the max quality for download alac")
|
||||
@@ -1155,21 +1159,33 @@ func extractMediaQuality(b string) (string, error) {
|
||||
})
|
||||
var Quality string
|
||||
for _, variant := range master.Variants {
|
||||
if variant.Codecs == "alac" {
|
||||
split := strings.Split(variant.Audio, "-")
|
||||
length := len(split)
|
||||
length_int, err := strconv.Atoi(split[length-2])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if length_int <= Config.AlacMax {
|
||||
HZ, err := strconv.Atoi(split[length-2])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
if dl_aac {
|
||||
if variant.Codecs == "mp4a.40.2" {
|
||||
aacregex := regexp.MustCompile(`audio-stereo-\d+`)
|
||||
replaced := aacregex.ReplaceAllString(variant.Audio, "aac")
|
||||
split := strings.Split(variant.Audio, "-")
|
||||
if replaced == Config.AacType {
|
||||
Quality = fmt.Sprintf("%skbps", split[2])
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if variant.Codecs == "alac" {
|
||||
split := strings.Split(variant.Audio, "-")
|
||||
length := len(split)
|
||||
length_int, err := strconv.Atoi(split[length-2])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if length_int <= Config.AlacMax {
|
||||
HZ, err := strconv.Atoi(split[length-2])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
KHZ := float64(HZ) / 1000.0
|
||||
Quality = fmt.Sprintf("%sB-%.1fkHz", split[length-1], KHZ)
|
||||
break
|
||||
}
|
||||
KHZ := float64(HZ) / 1000.0
|
||||
Quality = fmt.Sprintf("%sB-%.1fkHz", split[length-1], KHZ)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1222,6 +1238,21 @@ func extractMedia(b string) (string, error) {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if dl_aac {
|
||||
if variant.Codecs == "mp4a.40.2" {
|
||||
aacregex := regexp.MustCompile(`audio-stereo-\d+`)
|
||||
replaced := aacregex.ReplaceAllString(variant.Audio, "aac")
|
||||
//split := strings.Split(variant.Audio, "-")
|
||||
if replaced == Config.AacType {
|
||||
fmt.Printf("%s\n", variant.Audio)
|
||||
streamUrlTemp, err := masterUrl.Parse(variant.URI)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
streamUrl = streamUrlTemp
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if variant.Codecs == "alac" {
|
||||
split := strings.Split(variant.Audio, "-")
|
||||
|
||||
@@ -28,6 +28,7 @@ type ConfigSet struct {
|
||||
GetM3u8Port string `yaml:"get-m3u8-port"`
|
||||
GetM3u8Mode string `yaml:"get-m3u8-mode"`
|
||||
GetM3u8FromDevice bool `yaml:"get-m3u8-from-device"`
|
||||
AacType string `yaml:"aac-type"`
|
||||
AlacMax int `yaml:"alac-max"`
|
||||
AtmosMax int `yaml:"atmos-max"`
|
||||
LimitMax int `yaml:"limit-max"`
|
||||
|
||||
Reference in New Issue
Block a user