|
|
|
@ -29,7 +29,6 @@ import ( |
|
|
|
|
"github.com/abema/go-mp4" |
|
|
|
|
"github.com/beevik/etree" |
|
|
|
|
"github.com/grafov/m3u8" |
|
|
|
|
"github.com/schollz/progressbar/v3" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
@ -97,7 +96,6 @@ type SongInfo struct { |
|
|
|
|
r io.ReadSeeker |
|
|
|
|
alacParam *Alac |
|
|
|
|
samples []SampleInfo |
|
|
|
|
totalDataSize int64 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func loadConfig() error { |
|
|
|
@ -979,22 +977,7 @@ func decryptSong(info *SongInfo, keys []string, manifest *AutoGenerated, filenam |
|
|
|
|
var decrypted []byte |
|
|
|
|
var lastIndex uint32 = math.MaxUint8 |
|
|
|
|
|
|
|
|
|
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: "", |
|
|
|
|
}), |
|
|
|
|
) |
|
|
|
|
fmt.Println("Decrypt start.") |
|
|
|
|
for _, sp := range info.samples { |
|
|
|
|
if lastIndex != sp.descIndex { |
|
|
|
|
if len(decrypted) != 0 { |
|
|
|
@ -1046,11 +1029,10 @@ 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("Decrypted.") |
|
|
|
|
fmt.Println("Decrypt finished.") |
|
|
|
|
|
|
|
|
|
create, err := os.Create(filename) |
|
|
|
|
if err != nil { |
|
|
|
@ -1721,15 +1703,12 @@ 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 { |
|
|
|
@ -2331,6 +2310,7 @@ func extractVideo(c string) (string, error) { |
|
|
|
|
return streamUrl.String(), nil |
|
|
|
|
} |
|
|
|
|
func extractSong(url string) (*SongInfo, error) { |
|
|
|
|
fmt.Println("Downloading...") |
|
|
|
|
track, err := http.Get(url) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
@ -2339,24 +2319,7 @@ func extractSong(url string) (*SongInfo, error) { |
|
|
|
|
if track.StatusCode != http.StatusOK { |
|
|
|
|
return nil, errors.New(track.Status) |
|
|
|
|
} |
|
|
|
|
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)) |
|
|
|
|
rawSong, err := ioutil.ReadAll(track.Body) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|