mirror of
https://github.com/zhaarey/apple-music-downloader.git
synced 2025-10-23 15:11:05 +00:00
Update main.go
This commit is contained in:
32
main.go
32
main.go
@@ -97,6 +97,7 @@ type SongInfo struct {
|
|||||||
r io.ReadSeeker
|
r io.ReadSeeker
|
||||||
alacParam *Alac
|
alacParam *Alac
|
||||||
samples []SampleInfo
|
samples []SampleInfo
|
||||||
|
totalDataSize int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig() error {
|
func loadConfig() error {
|
||||||
@@ -978,7 +979,22 @@ func decryptSong(info *SongInfo, keys []string, manifest *AutoGenerated, filenam
|
|||||||
var decrypted []byte
|
var decrypted []byte
|
||||||
var lastIndex uint32 = math.MaxUint8
|
var lastIndex uint32 = math.MaxUint8
|
||||||
|
|
||||||
fmt.Println("Decrypt start.")
|
bar := progressbar.NewOptions64(info.totalDataSize,
|
||||||
|
progressbar.OptionClearOnFinish(),
|
||||||
|
progressbar.OptionSetElapsedTime(true),
|
||||||
|
progressbar.OptionShowElapsedTimeOnFinish(),
|
||||||
|
progressbar.OptionShowCount(),
|
||||||
|
progressbar.OptionEnableColorCodes(true),
|
||||||
|
progressbar.OptionShowBytes(true),
|
||||||
|
progressbar.OptionSetDescription("Decrypting..."),
|
||||||
|
progressbar.OptionSetTheme(progressbar.Theme{
|
||||||
|
Saucer: "",
|
||||||
|
SaucerHead: "",
|
||||||
|
SaucerPadding: "",
|
||||||
|
BarStart: "",
|
||||||
|
BarEnd: "",
|
||||||
|
}),
|
||||||
|
)
|
||||||
for _, sp := range info.samples {
|
for _, sp := range info.samples {
|
||||||
if lastIndex != sp.descIndex {
|
if lastIndex != sp.descIndex {
|
||||||
if len(decrypted) != 0 {
|
if len(decrypted) != 0 {
|
||||||
@@ -1030,10 +1046,11 @@ func decryptSong(info *SongInfo, keys []string, manifest *AutoGenerated, filenam
|
|||||||
}
|
}
|
||||||
|
|
||||||
decrypted = append(decrypted, de...)
|
decrypted = append(decrypted, de...)
|
||||||
|
bar.Add(len(sp.data))
|
||||||
}
|
}
|
||||||
_, _ = conn.Write([]byte{0, 0, 0, 0, 0})
|
_, _ = conn.Write([]byte{0, 0, 0, 0, 0})
|
||||||
|
|
||||||
fmt.Println("Decrypt finished.")
|
fmt.Println("Decrypted.")
|
||||||
|
|
||||||
create, err := os.Create(filename)
|
create, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1704,12 +1721,15 @@ func rip(albumId string, token string, storefront string, userToken string) erro
|
|||||||
}
|
}
|
||||||
samplesOk := true
|
samplesOk := true
|
||||||
for samplesOk {
|
for samplesOk {
|
||||||
|
var totalSize int64 = 0
|
||||||
for _, i := range info.samples {
|
for _, i := range info.samples {
|
||||||
|
totalSize += int64(len(i.data))
|
||||||
if int(i.descIndex) >= len(keys) {
|
if int(i.descIndex) >= len(keys) {
|
||||||
fmt.Println("Decryption size mismatch.")
|
fmt.Println("Decryption size mismatch.")
|
||||||
samplesOk = false
|
samplesOk = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
info.totalDataSize = totalSize
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !samplesOk {
|
if !samplesOk {
|
||||||
@@ -2321,12 +2341,20 @@ func extractSong(url string) (*SongInfo, error) {
|
|||||||
}
|
}
|
||||||
contentLength := track.ContentLength
|
contentLength := track.ContentLength
|
||||||
bar := progressbar.NewOptions64(contentLength,
|
bar := progressbar.NewOptions64(contentLength,
|
||||||
|
progressbar.OptionClearOnFinish(),
|
||||||
progressbar.OptionSetElapsedTime(true),
|
progressbar.OptionSetElapsedTime(true),
|
||||||
progressbar.OptionShowElapsedTimeOnFinish(),
|
progressbar.OptionShowElapsedTimeOnFinish(),
|
||||||
progressbar.OptionShowCount(),
|
progressbar.OptionShowCount(),
|
||||||
progressbar.OptionEnableColorCodes(true),
|
progressbar.OptionEnableColorCodes(true),
|
||||||
progressbar.OptionShowBytes(true),
|
progressbar.OptionShowBytes(true),
|
||||||
progressbar.OptionSetDescription("Downloading..."),
|
progressbar.OptionSetDescription("Downloading..."),
|
||||||
|
progressbar.OptionSetTheme(progressbar.Theme{
|
||||||
|
Saucer: "",
|
||||||
|
SaucerHead: "",
|
||||||
|
SaucerPadding: "",
|
||||||
|
BarStart: "",
|
||||||
|
BarEnd: "",
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
rawSong, err := ioutil.ReadAll(io.TeeReader(track.Body, bar))
|
rawSong, err := ioutil.ReadAll(io.TeeReader(track.Body, bar))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user