mirror of
https://git.um-react.app/um/cli.git
synced 2025-11-28 03:33:02 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa8f7a1565 | ||
|
|
d4d5e5ddf4 | ||
|
|
57c1aa3e54 | ||
|
|
b0998d8c8a | ||
|
|
f819726f3e | ||
|
|
fbad7ec450 | ||
|
|
19bc6c466e | ||
|
|
b9e2a38f82 | ||
|
|
673ea8491f |
@@ -17,25 +17,36 @@ local CreateRelease() = {
|
|||||||
|
|
||||||
|
|
||||||
local StepGoBuild(GOOS, GOARCH) = {
|
local StepGoBuild(GOOS, GOARCH) = {
|
||||||
local filepath = 'dist/um-%s-%s.tar.gz' % [GOOS, GOARCH],
|
local windows = GOOS == 'windows',
|
||||||
|
local archiveExt = if windows then 'zip' else 'tar.gz',
|
||||||
|
local filepath = 'dist/um-%s-%s.%s' % [GOOS, GOARCH, archiveExt],
|
||||||
|
|
||||||
|
local archive = if windows then [
|
||||||
|
// Ensure zip is installed
|
||||||
|
'command -v zip >/dev/null || (apt update && apt install -y zip)',
|
||||||
|
'zip -9 -j -r "%s" $DIST_DIR' % filepath,
|
||||||
|
] else [
|
||||||
|
'tar -zc -C $DIST_DIR um | gzip -9 > "%s"' % filepath,
|
||||||
|
],
|
||||||
|
|
||||||
name: 'go build %s/%s' % [GOOS, GOARCH],
|
name: 'go build %s/%s' % [GOOS, GOARCH],
|
||||||
image: 'golang:1.22',
|
image: 'golang:1.22',
|
||||||
environment: {
|
environment: {
|
||||||
GOOS: GOOS,
|
GOOS: GOOS,
|
||||||
GOARCH: GOARCH,
|
GOARCH: GOARCH,
|
||||||
GOPROXY: "https://goproxy.io,direct",
|
GOPROXY: 'https://goproxy.io,direct',
|
||||||
},
|
},
|
||||||
commands: [
|
commands: [
|
||||||
'DIST_DIR=$(mktemp -d)',
|
'DIST_DIR=$(mktemp -d)',
|
||||||
'go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --always)" -o $DIST_DIR ./cmd/um',
|
'go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --always)" -o $DIST_DIR ./cmd/um',
|
||||||
'mkdir -p dist',
|
'mkdir -p dist',
|
||||||
'tar cz -f %s -C $DIST_DIR .' % filepath,
|
] + archive,
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
local StepUploadArtifact(GOOS, GOARCH) = {
|
local StepUploadArtifact(GOOS, GOARCH) = {
|
||||||
local filename = 'um-%s-%s.tar.gz' % [GOOS, GOARCH],
|
local windows = GOOS == 'windows',
|
||||||
|
local archiveExt = if windows then 'zip' else 'tar.gz',
|
||||||
|
local filename = 'um-%s-%s.%s' % [GOOS, GOARCH, archiveExt],
|
||||||
local filepath = 'dist/%s' % filename,
|
local filepath = 'dist/%s' % filename,
|
||||||
local pkgname = '${DRONE_REPO_NAME}-build',
|
local pkgname = '${DRONE_REPO_NAME}-build',
|
||||||
|
|
||||||
@@ -71,7 +82,7 @@ local PipelineBuild(GOOS, GOARCH, RUN_TEST) = {
|
|||||||
name: 'go test',
|
name: 'go test',
|
||||||
image: 'golang:1.22',
|
image: 'golang:1.22',
|
||||||
environment: {
|
environment: {
|
||||||
GOPROXY: "https://goproxy.io,direct",
|
GOPROXY: 'https://goproxy.io,direct',
|
||||||
},
|
},
|
||||||
commands: ['go test -v ./...'],
|
commands: ['go test -v ./...'],
|
||||||
}] else []
|
}] else []
|
||||||
@@ -100,7 +111,7 @@ local PipelineRelease() = {
|
|||||||
name: 'go test',
|
name: 'go test',
|
||||||
image: 'golang:1.22',
|
image: 'golang:1.22',
|
||||||
environment: {
|
environment: {
|
||||||
GOPROXY: "https://goproxy.io,direct",
|
GOPROXY: 'https://goproxy.io,direct',
|
||||||
},
|
},
|
||||||
commands: ['go test -v ./...'],
|
commands: ['go test -v ./...'],
|
||||||
},
|
},
|
||||||
|
|||||||
29
.drone.yml
29
.drone.yml
@@ -17,7 +17,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-linux-amd64.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -53,7 +53,8 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-windows-amd64.tar.gz -C $DIST_DIR .
|
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||||
|
- zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
|
||||||
environment:
|
environment:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: windows
|
GOOS: windows
|
||||||
@@ -61,9 +62,9 @@ steps:
|
|||||||
image: golang:1.22
|
image: golang:1.22
|
||||||
name: go build windows/amd64
|
name: go build windows/amd64
|
||||||
- commands:
|
- commands:
|
||||||
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-windows-amd64.tar.gz"
|
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-windows-amd64.zip"
|
||||||
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64.tar.gz"
|
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64.zip"
|
||||||
- sha256sum dist/um-windows-amd64.tar.gz
|
- sha256sum dist/um-windows-amd64.zip
|
||||||
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
|
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
|
||||||
environment:
|
environment:
|
||||||
DRONE_GITEA_SERVER: https://git.unlock-music.dev
|
DRONE_GITEA_SERVER: https://git.unlock-music.dev
|
||||||
@@ -89,7 +90,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-darwin-amd64.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: darwin
|
GOOS: darwin
|
||||||
@@ -131,7 +132,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-linux-amd64.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -143,7 +144,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-linux-arm64.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-arm64.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: arm64
|
GOARCH: arm64
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -155,7 +156,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-linux-386.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-386.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: "386"
|
GOARCH: "386"
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -167,7 +168,8 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-windows-amd64.tar.gz -C $DIST_DIR .
|
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||||
|
- zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
|
||||||
environment:
|
environment:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: windows
|
GOOS: windows
|
||||||
@@ -179,7 +181,8 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-windows-386.tar.gz -C $DIST_DIR .
|
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||||
|
- zip -9 -j -r "dist/um-windows-386.zip" $DIST_DIR
|
||||||
environment:
|
environment:
|
||||||
GOARCH: "386"
|
GOARCH: "386"
|
||||||
GOOS: windows
|
GOOS: windows
|
||||||
@@ -191,7 +194,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-darwin-amd64.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: darwin
|
GOOS: darwin
|
||||||
@@ -203,7 +206,7 @@ steps:
|
|||||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||||
--always)" -o $DIST_DIR ./cmd/um
|
--always)" -o $DIST_DIR ./cmd/um
|
||||||
- mkdir -p dist
|
- mkdir -p dist
|
||||||
- tar cz -f dist/um-darwin-arm64.tar.gz -C $DIST_DIR .
|
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-arm64.tar.gz"
|
||||||
environment:
|
environment:
|
||||||
GOARCH: arm64
|
GOARCH: arm64
|
||||||
GOOS: darwin
|
GOOS: darwin
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -6,6 +6,9 @@ Original: Web Edition https://git.unlock-music.dev/um/web
|
|||||||
- [Release Download](https://git.unlock-music.dev/um/cli/releases/latest)
|
- [Release Download](https://git.unlock-music.dev/um/cli/releases/latest)
|
||||||
- [Latest Build](https://git.unlock-music.dev/um/-/packages/generic/cli-build/)
|
- [Latest Build](https://git.unlock-music.dev/um/-/packages/generic/cli-build/)
|
||||||
|
|
||||||
|
> **WARNING**
|
||||||
|
> 在本站 fork 不会起到备份的作用,只会浪费服务器储存空间。如无必要请勿 fork 该仓库。
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- [x] All Algorithm Supported By `unlock-music/web`
|
- [x] All Algorithm Supported By `unlock-music/web`
|
||||||
@@ -22,3 +25,13 @@ Original: Web Edition https://git.unlock-music.dev/um/web
|
|||||||
- Drag the encrypted file to `um.exe` (Tested on Windows)
|
- Drag the encrypted file to `um.exe` (Tested on Windows)
|
||||||
- Run: `./um [-o <output dir>] [-i] <input dir/file>`
|
- Run: `./um [-o <output dir>] [-i] <input dir/file>`
|
||||||
- Use `./um -h` to show help menu
|
- Use `./um -h` to show help menu
|
||||||
|
|
||||||
|
## Update CI pipeline
|
||||||
|
|
||||||
|
1. Install [Drone CI binary](https://docs.drone.io/cli/install/)
|
||||||
|
2. Edit `.drone.jsonnet`
|
||||||
|
3. Update drone CI pipeline:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
drone jsonnet --format --stream
|
||||||
|
```
|
||||||
|
|||||||
@@ -18,25 +18,32 @@ type DecoderParams struct {
|
|||||||
}
|
}
|
||||||
type NewDecoderFunc func(p *DecoderParams) Decoder
|
type NewDecoderFunc func(p *DecoderParams) Decoder
|
||||||
|
|
||||||
type decoderItem struct {
|
type DecoderFactory struct {
|
||||||
noop bool
|
noop bool
|
||||||
decoder NewDecoderFunc
|
Suffix string
|
||||||
|
Create NewDecoderFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
var DecoderRegistry = make(map[string][]decoderItem)
|
var DecoderRegistry []DecoderFactory
|
||||||
|
|
||||||
func RegisterDecoder(ext string, noop bool, dispatchFunc NewDecoderFunc) {
|
func RegisterDecoder(ext string, noop bool, dispatchFunc NewDecoderFunc) {
|
||||||
DecoderRegistry[ext] = append(DecoderRegistry[ext],
|
DecoderRegistry = append(DecoderRegistry,
|
||||||
decoderItem{noop: noop, decoder: dispatchFunc})
|
DecoderFactory{noop: noop, Create: dispatchFunc, Suffix: "." + strings.TrimPrefix(ext, ".")})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDecoder(filename string, skipNoop bool) (rs []NewDecoderFunc) {
|
func GetDecoder(filename string, skipNoop bool) []DecoderFactory {
|
||||||
ext := strings.ToLower(strings.TrimLeft(filepath.Ext(filename), "."))
|
var result []DecoderFactory
|
||||||
for _, dec := range DecoderRegistry[ext] {
|
// Some extensions contains multiple dots, e.g. ".kgm.flac", hence iterate
|
||||||
|
// all decoders for each extension.
|
||||||
|
name := strings.ToLower(filepath.Base(filename))
|
||||||
|
for _, dec := range DecoderRegistry {
|
||||||
|
if !strings.HasSuffix(name, dec.Suffix) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if skipNoop && dec.noop {
|
if skipNoop && dec.noop {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
rs = append(rs, dec.decoder)
|
result = append(result, dec)
|
||||||
}
|
}
|
||||||
return
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,7 @@ func init() {
|
|||||||
common.RegisterDecoder("kgma", false, NewDecoder)
|
common.RegisterDecoder("kgma", false, NewDecoder)
|
||||||
// Viper
|
// Viper
|
||||||
common.RegisterDecoder("vpr", false, NewDecoder)
|
common.RegisterDecoder("vpr", false, NewDecoder)
|
||||||
|
// Kugou Android
|
||||||
|
common.RegisterDecoder("kgm.flac", false, NewDecoder)
|
||||||
|
common.RegisterDecoder("vpr.flac", false, NewDecoder)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import (
|
|||||||
"unlock-music.dev/cli/internal/utils"
|
"unlock-music.dev/cli/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AppVersion = "v0.2.3"
|
var AppVersion = "v0.2.5"
|
||||||
|
|
||||||
var logger, _ = logging.NewZapLogger() // TODO: inject logger to application, instead of using global logger
|
var logger, _ = logging.NewZapLogger() // TODO: inject logger to application, instead of using global logger
|
||||||
|
|
||||||
@@ -75,12 +75,21 @@ func main() {
|
|||||||
|
|
||||||
func printSupportedExtensions() {
|
func printSupportedExtensions() {
|
||||||
var exts []string
|
var exts []string
|
||||||
for ext := range common.DecoderRegistry {
|
extSet := make(map[string]int)
|
||||||
|
for _, factory := range common.DecoderRegistry {
|
||||||
|
ext := strings.TrimPrefix(factory.Suffix, ".")
|
||||||
|
if n, ok := extSet[ext]; ok {
|
||||||
|
extSet[ext] = n + 1
|
||||||
|
} else {
|
||||||
|
extSet[ext] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ext := range extSet {
|
||||||
exts = append(exts, ext)
|
exts = append(exts, ext)
|
||||||
}
|
}
|
||||||
sort.Strings(exts)
|
sort.Strings(exts)
|
||||||
for _, ext := range exts {
|
for _, ext := range exts {
|
||||||
fmt.Printf("%s: %d\n", ext, len(common.DecoderRegistry[ext]))
|
fmt.Printf("%s: %d\n", ext, extSet[ext])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +285,19 @@ func (p *processor) processFile(filePath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) error {
|
func (p *processor) findDecoder(decoders []common.DecoderFactory, params *common.DecoderParams) (*common.Decoder, *common.DecoderFactory, error) {
|
||||||
|
for _, factory := range decoders {
|
||||||
|
dec := factory.Create(params)
|
||||||
|
err := dec.Validate()
|
||||||
|
if err == nil {
|
||||||
|
return &dec, &factory, nil
|
||||||
|
}
|
||||||
|
logger.Warn("try decode failed", zap.Error(err))
|
||||||
|
}
|
||||||
|
return nil, nil, errors.New("no any decoder can resolve the file")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *processor) process(inputFile string, allDec []common.DecoderFactory) error {
|
||||||
file, err := os.Open(inputFile)
|
file, err := os.Open(inputFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -284,26 +305,16 @@ func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) er
|
|||||||
defer file.Close()
|
defer file.Close()
|
||||||
logger := logger.With(zap.String("source", inputFile))
|
logger := logger.With(zap.String("source", inputFile))
|
||||||
|
|
||||||
decParams := &common.DecoderParams{
|
pDec, decoderFactory, err := p.findDecoder(allDec, &common.DecoderParams{
|
||||||
Reader: file,
|
Reader: file,
|
||||||
Extension: filepath.Ext(inputFile),
|
Extension: filepath.Ext(inputFile),
|
||||||
FilePath: inputFile,
|
FilePath: inputFile,
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
dec := *pDec
|
||||||
var dec common.Decoder
|
|
||||||
for _, decFunc := range allDec {
|
|
||||||
dec = decFunc(decParams)
|
|
||||||
if err := dec.Validate(); err == nil {
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
logger.Warn("try decode failed", zap.Error(err))
|
|
||||||
dec = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if dec == nil {
|
|
||||||
return errors.New("no any decoder can resolve the file")
|
|
||||||
}
|
|
||||||
|
|
||||||
params := &ffmpeg.UpdateMetadataParams{}
|
params := &ffmpeg.UpdateMetadataParams{}
|
||||||
|
|
||||||
@@ -365,13 +376,14 @@ func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) er
|
|||||||
return fmt.Errorf("get relative dir failed: %w", err)
|
return fmt.Errorf("get relative dir failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
inFilename := strings.TrimSuffix(filepath.Base(inputFile), filepath.Ext(inputFile))
|
inFilename := strings.TrimSuffix(filepath.Base(inputFile), decoderFactory.Suffix)
|
||||||
outPath := filepath.Join(p.outputDir, inputRelDir, inFilename+params.AudioExt)
|
outPath := filepath.Join(p.outputDir, inputRelDir, inFilename+params.AudioExt)
|
||||||
|
|
||||||
if !p.overwriteOutput {
|
if !p.overwriteOutput {
|
||||||
_, err := os.Stat(outPath)
|
_, err := os.Stat(outPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("output file %s is already exist", outPath)
|
logger.Warn("output file already exist, skip", zap.String("destination", outPath))
|
||||||
|
return nil
|
||||||
} else if !errors.Is(err, os.ErrNotExist) {
|
} else if !errors.Is(err, os.ErrNotExist) {
|
||||||
return fmt.Errorf("stat output file failed: %w", err)
|
return fmt.Errorf("stat output file failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user