Compare commits

..

2 Commits

Author SHA1 Message Date
TaurusXin ab1c9fcf0b
fix: build script 2024-09-15 21:52:54 +08:00
TaurusXin da31a12acb
feat: docs for functions 2024-09-15 21:51:32 +08:00
2 changed files with 14 additions and 5 deletions

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash
# Linux amd64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_linux_amd64 ncmdump
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_linux_amd64 github.com/taurusxin/ncmdump-go
# macOS amd64
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_darwin_amd64 ncmdump
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_darwin_amd64 github.com/taurusxin/ncmdump-go
# macOS arm64
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o ./build/ncmdump_darwin_arm64 ncmdump
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o ./build/ncmdump_darwin_arm64 github.com/taurusxin/ncmdump-go
# Windows amd64
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_windows_amd64.exe ncmdump
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o ./build/ncmdump_windows_amd64.exe github.com/taurusxin/ncmdump-go

View File

@ -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},