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