Compare commits
5 Commits
0c9fc960ff
...
1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
30a50c1eae
|
|||
|
d396c91e90
|
|||
|
ee68843d9e
|
|||
|
ab1c9fcf0b
|
|||
|
da31a12acb
|
32
build.sh
32
build.sh
@@ -1,13 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERSION=1.5.0
|
||||
|
||||
# Clean up the build directory
|
||||
rm -rf build
|
||||
mkdir build
|
||||
|
||||
# Linux amd64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_linux_amd64 ncmdump
|
||||
echo "Building for Linux amd64..."
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o build/ncmdump github.com/taurusxin/ncmdump-go
|
||||
tar zcf build/ncmdump_linux_amd64_$VERSION.tar.gz -C build ncmdump
|
||||
rm build/ncmdump
|
||||
|
||||
# Linux arm64
|
||||
echo "Building for Linux arm64..."
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o build/ncmdump github.com/taurusxin/ncmdump-go
|
||||
tar zcf build/ncmdump_linux_arm64_$VERSION.tar.gz -C build ncmdump
|
||||
rm build/ncmdump
|
||||
|
||||
# macOS amd64
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_darwin_amd64 ncmdump
|
||||
echo "Building for macOS amd64..."
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o build/ncmdump github.com/taurusxin/ncmdump-go
|
||||
tar zcf build/ncmdump_darwin_amd64_$VERSION.tar.gz -C build ncmdump
|
||||
rm build/ncmdump
|
||||
|
||||
# macOS arm64
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o ./build/ncmdump_darwin_arm64 ncmdump
|
||||
echo "Building for macOS arm64..."
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o build/ncmdump github.com/taurusxin/ncmdump-go
|
||||
tar zcf build/ncmdump_darwin_arm64_$VERSION.tar.gz -C build ncmdump
|
||||
rm build/ncmdump
|
||||
|
||||
# Windows amd64
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_windows_amd64.exe ncmdump
|
||||
echo "Building for Windows amd64..."
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o build/ncmdump.exe github.com/taurusxin/ncmdump-go
|
||||
zip -q -j build/ncmdump_windows_amd64_$VERSION.zip ./build/ncmdump.exe
|
||||
rm build/ncmdump.exe
|
||||
8
main.go
8
main.go
@@ -13,18 +13,18 @@ import (
|
||||
func processFile(filePath string) error {
|
||||
currentFile, err := ncmcrypt.NewNeteaseCloudMusic(filePath)
|
||||
if err != nil {
|
||||
utils.ErrorPrintfln("Reading '%s' failed: '%s'", filePath, err.Error())
|
||||
utils.ErrorPrintfln("Reading '%s' failed: %s", filePath, err.Error())
|
||||
return err
|
||||
}
|
||||
dump, err := currentFile.Dump(filepath.Dir(filePath))
|
||||
if err != nil {
|
||||
utils.ErrorPrintfln("Processing '%s' failed: '%s'", filePath, err.Error())
|
||||
utils.ErrorPrintfln("Processing '%s' failed: %s", filePath, err.Error())
|
||||
return err
|
||||
}
|
||||
if dump {
|
||||
metadata, err := currentFile.FixMetadata(true)
|
||||
if !metadata {
|
||||
utils.WarningPrintfln("Fix metadata for '%s' failed: '%s'", filePath, err.Error())
|
||||
utils.WarningPrintfln("Fix metadata for '%s' failed: %s", filePath, err.Error())
|
||||
return err
|
||||
}
|
||||
utils.DonePrintfln("'%s' -> '%s'", filePath, currentFile.GetDumpFilePath())
|
||||
@@ -63,7 +63,7 @@ func main() {
|
||||
}
|
||||
|
||||
if !info.IsDir() {
|
||||
utils.ErrorPrintfln("Not a directory: '%s'", folderPath)
|
||||
utils.ErrorPrintfln("Not a directory: %s", folderPath)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ func (ncm *NeteaseCloudMusic) mimeType() string {
|
||||
return "image/jpeg"
|
||||
}
|
||||
|
||||
// Dump encrypted ncm file to normal music file. If `targetDir` is "", the converted file will be saved to the original directory.
|
||||
func (ncm *NeteaseCloudMusic) Dump(targetDir string) (bool, error) {
|
||||
ncm.mDumpFilePath = ncm.mFilePath
|
||||
var outputStream *os.File
|
||||
@@ -157,6 +158,8 @@ func (ncm *NeteaseCloudMusic) Dump(targetDir string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// FixMetadata will fix the missing metadata for target music file, the source of the metadata comes from origin ncm file.
|
||||
// Since NeteaseCloudMusic version 3.0, the album cover image is no longer embedded in the ncm file. If the parameter is true, it means downloading the image from the NetEase server and embedding it into the target music file (network connection required)
|
||||
func (ncm *NeteaseCloudMusic) FixMetadata(fetchAlbumImageFromRemote bool) (bool, error) {
|
||||
if fetchAlbumImageFromRemote {
|
||||
// get the album pic from url
|
||||
@@ -226,10 +229,16 @@ func (ncm *NeteaseCloudMusic) FixMetadata(fetchAlbumImageFromRemote bool) (bool,
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetDumpFilePath returns the absolute path of dumped music file
|
||||
func (ncm *NeteaseCloudMusic) GetDumpFilePath() string {
|
||||
path, err := filepath.Abs(ncm.mDumpFilePath)
|
||||
if err != nil {
|
||||
return ncm.mDumpFilePath
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// NewNeteaseCloudMusic returns a new NeteaseCloudMusic instance, if the format of the file is incorrect, the error will be returned.
|
||||
func NewNeteaseCloudMusic(filePath string) (*NeteaseCloudMusic, error) {
|
||||
ncm := &NeteaseCloudMusic{
|
||||
sCoreKey: [17]byte{0x68, 0x7A, 0x48, 0x52, 0x41, 0x6D, 0x73, 0x6F, 0x35, 0x6B, 0x49, 0x6E, 0x62, 0x61, 0x78, 0x57, 0},
|
||||
|
||||
Reference in New Issue
Block a user