mirror of
https://git.um-react.app/um/cli.git
synced 2026-10-20 13:33:01 +00:00
feat: add flags to ignore known non-music file extensions and update processor logic to support this feature
This commit is contained in:
+3
-1
@@ -7,13 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v0.2.20] - 2026-10-18
|
||||
## [v0.2.20] - 2026-10-20
|
||||
|
||||
### Added
|
||||
|
||||
- [#2] Support `.mflac2` / `.mgg2` extensions.
|
||||
- [#7] Load QMC ekeys from QQ Music Android `player_process_db` (`--qmc-android-db`).
|
||||
- [#8] Windows: auto-fetch QMC keys via `qmpc-mmkv-cli` (`--qmpc-mmkv-cli-exe`).
|
||||
- [#5] `--ignore-known-non-music-ext` / `--no-ignore-known-non-music-ext` (default on): skip files with no extension or known non-music file.
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
+25
-11
@@ -56,6 +56,8 @@ func main() {
|
||||
&cli.StringFlag{Name: "kgg-db", Usage: "path to kgg db (win32 kugou v11)", Required: false},
|
||||
&cli.BoolFlag{Name: "remove-source", Aliases: []string{"rs"}, Usage: "remove source file", Required: false, Value: false},
|
||||
&cli.BoolFlag{Name: "skip-noop", Aliases: []string{"n"}, Usage: "skip noop decoder", Required: false, Value: true},
|
||||
&cli.BoolFlag{Name: "ignore-known-non-music-ext", Usage: "skip files with no extension or known non-music extensions (txt, mmkv, exe, dll)", Required: false, Value: true},
|
||||
&cli.BoolFlag{Name: "no-ignore-known-non-music-ext", Usage: "do not skip known non-music extensions", Required: false, Value: false},
|
||||
&cli.BoolFlag{Name: "verbose", Aliases: []string{"V"}, Usage: "verbose logging", Required: false, Value: false},
|
||||
&cli.BoolFlag{Name: "update-metadata", Usage: "update metadata & album art from network", Required: false, Value: false},
|
||||
&cli.BoolFlag{Name: "overwrite", Usage: "overwrite output file without asking", Required: false, Value: false},
|
||||
@@ -204,14 +206,20 @@ func appMain(c *cli.Context) (err error) {
|
||||
kggDbPath = filepath.Join(os.Getenv("APPDATA"), "Kugou8", "KGMusicV3.db")
|
||||
}
|
||||
|
||||
ignoreKnownNonMusicExt := c.Bool("ignore-known-non-music-ext")
|
||||
if c.Bool("no-ignore-known-non-music-ext") {
|
||||
ignoreKnownNonMusicExt = false
|
||||
}
|
||||
|
||||
proc := &processor{
|
||||
logger: logger,
|
||||
inputDir: inputDir,
|
||||
outputDir: output,
|
||||
skipNoopDecoder: c.Bool("skip-noop"),
|
||||
removeSource: c.Bool("remove-source"),
|
||||
updateMetadata: c.Bool("update-metadata"),
|
||||
overwriteOutput: c.Bool("overwrite"),
|
||||
logger: logger,
|
||||
inputDir: inputDir,
|
||||
outputDir: output,
|
||||
skipNoopDecoder: c.Bool("skip-noop"),
|
||||
ignoreKnownNonMusicExt: ignoreKnownNonMusicExt,
|
||||
removeSource: c.Bool("remove-source"),
|
||||
updateMetadata: c.Bool("update-metadata"),
|
||||
overwriteOutput: c.Bool("overwrite"),
|
||||
|
||||
crypto: common.CryptoParams{
|
||||
// KuGou
|
||||
@@ -240,10 +248,11 @@ type processor struct {
|
||||
inputDir string
|
||||
outputDir string
|
||||
|
||||
skipNoopDecoder bool
|
||||
removeSource bool
|
||||
updateMetadata bool
|
||||
overwriteOutput bool
|
||||
skipNoopDecoder bool
|
||||
ignoreKnownNonMusicExt bool
|
||||
removeSource bool
|
||||
updateMetadata bool
|
||||
overwriteOutput bool
|
||||
|
||||
crypto common.CryptoParams
|
||||
}
|
||||
@@ -330,6 +339,11 @@ func (p *processor) processDir(inputDir string) error {
|
||||
}
|
||||
|
||||
func (p *processor) processFile(filePath string) error {
|
||||
if p.ignoreKnownNonMusicExt && isKnownNonMusicExt(filePath) {
|
||||
p.logger.Debug("skip known non-music extension", zap.String("file", filePath))
|
||||
return nil
|
||||
}
|
||||
|
||||
p.logger.Debug("processFile", zap.String("file", filePath), zap.String("inputDir", p.inputDir))
|
||||
|
||||
allDec := common.GetDecoder(filePath, p.skipNoopDecoder)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// knownNonMusicExts are common non-audio suffixes to skip when walking dirs.
|
||||
var knownNonMusicExts = []string{
|
||||
"",
|
||||
".txt",
|
||||
".mmkv",
|
||||
".exe",
|
||||
".dll",
|
||||
}
|
||||
|
||||
func isKnownNonMusicExt(path string) bool {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
return slices.Contains(knownNonMusicExts, ext)
|
||||
}
|
||||
Reference in New Issue
Block a user