feat: allow change save dir
This commit is contained in:
parent
85a694777e
commit
3f1a58f2aa
2
main.go
2
main.go
|
@ -16,7 +16,7 @@ func processFile(filePath string) error {
|
||||||
utils.ErrorPrintfln("Reading '%s' failed: '%s'", filePath, err.Error())
|
utils.ErrorPrintfln("Reading '%s' failed: '%s'", filePath, err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dump, err := currentFile.Dump()
|
dump, err := currentFile.Dump(filepath.Dir(filePath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.ErrorPrintfln("Processing '%s' failed: '%s'", filePath, err.Error())
|
utils.ErrorPrintfln("Processing '%s' failed: '%s'", filePath, err.Error())
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"ncmdump/utils"
|
"ncmdump/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NcmFormat = string
|
type NcmFormat = string
|
||||||
|
@ -110,7 +111,7 @@ func (ncm *NeteaseCloudMusic) mimeType() string {
|
||||||
return "image/jpeg"
|
return "image/jpeg"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ncm *NeteaseCloudMusic) Dump() (bool, error) {
|
func (ncm *NeteaseCloudMusic) Dump(targetDir string) (bool, error) {
|
||||||
ncm.mDumpFilePath = ncm.mFilePath
|
ncm.mDumpFilePath = ncm.mFilePath
|
||||||
var outputStream *os.File
|
var outputStream *os.File
|
||||||
|
|
||||||
|
@ -137,6 +138,9 @@ func (ncm *NeteaseCloudMusic) Dump() (bool, error) {
|
||||||
ncm.mFormat = Flac
|
ncm.mFormat = Flac
|
||||||
ncm.mDumpFilePath = utils.ReplaceExtension(ncm.mDumpFilePath, ".flac")
|
ncm.mDumpFilePath = utils.ReplaceExtension(ncm.mDumpFilePath, ".flac")
|
||||||
}
|
}
|
||||||
|
if targetDir != "" { // change save dir
|
||||||
|
ncm.mDumpFilePath = filepath.Join(targetDir, filepath.Base(ncm.mDumpFilePath))
|
||||||
|
}
|
||||||
findFormatFlag = true
|
findFormatFlag = true
|
||||||
|
|
||||||
output, err := os.Create(ncm.mDumpFilePath)
|
output, err := os.Create(ncm.mDumpFilePath)
|
||||||
|
|
Loading…
Reference in New Issue