From 59f3759d489833176a126171bee9a46c48d5ae99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Wed, 4 Sep 2024 22:47:02 +0100 Subject: [PATCH 1/5] fix: add more extensions (Mac) #71 --- algo/qmc/qmc.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/algo/qmc/qmc.go b/algo/qmc/qmc.go index 651519a..511a42b 100644 --- a/algo/qmc/qmc.go +++ b/algo/qmc/qmc.go @@ -254,12 +254,20 @@ func init() { "6d3461", //QQ Music Weiyun M4a "776176", //QQ Music Weiyun Wav - "mgg", "mgg1", "mggl", //QQ Music New Ogg - "mflac", "mflac0", "mflach", //QQ Music New Flac - "mmp4", // QQ Music MP4 Container, tipically used for Dolby EAC3 stream } for _, ext := range supportedExts { common.RegisterDecoder(ext, false, NewDecoder) } + + // New ogg/flac: + extraExtsCanHaveSuffix := []string{"mgg", "mflac"} + // Mac also adds some extra suffix to ext: + extraExtSuffix := []string{"0", "1", "a", "h", "l"} + for _, ext := range extraExtsCanHaveSuffix { + common.RegisterDecoder(ext, false, NewDecoder) + for _, suffix := range extraExtSuffix { + common.RegisterDecoder(ext+suffix, false, NewDecoder) + } + } } From f258e3e8f2d958d4104855a335205d4e7fd66653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Wed, 4 Sep 2024 22:51:54 +0100 Subject: [PATCH 2/5] fix: remove file after completion #59 --- cmd/um/main.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/cmd/um/main.go b/cmd/um/main.go index cb48457..e023a11 100644 --- a/cmd/um/main.go +++ b/cmd/um/main.go @@ -254,7 +254,20 @@ func (p *processor) processFile(filePath string) error { if len(allDec) == 0 { logger.Fatal("skipping while no suitable decoder") } - return p.process(filePath, allDec) + + if err := p.process(filePath, allDec); err != nil { + return err + } + + // if source file need to be removed + if p.removeSource { + err := os.RemoveAll(filePath) + if err != nil { + return err + } + logger.Info("source file removed after success conversion", zap.String("source", filePath)) + } + return nil } func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) error { @@ -363,8 +376,6 @@ func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) er if _, err := io.Copy(outFile, audio); err != nil { return err } - outFile.Close() - } else { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -374,16 +385,6 @@ func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) er } } - // if source file need to be removed - if p.removeSource { - err := os.RemoveAll(inputFile) - if err != nil { - return err - } - logger.Info("successfully converted, and source file is removed", zap.String("source", inputFile), zap.String("destination", outPath)) - } else { - logger.Info("successfully converted", zap.String("source", inputFile), zap.String("destination", outPath)) - } - + logger.Info("successfully converted", zap.String("source", inputFile), zap.String("destination", outPath)) return nil } From cab705a130f96fe26d0422f27ecb29e58b1a6570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Wed, 4 Sep 2024 23:03:35 +0100 Subject: [PATCH 3/5] fix: typo in qmc-mmkv flag description --- cmd/um/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/um/main.go b/cmd/um/main.go index e023a11..8ba0c1f 100644 --- a/cmd/um/main.go +++ b/cmd/um/main.go @@ -50,7 +50,7 @@ func main() { Flags: []cli.Flag{ &cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: false}, &cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "path to output dir", Required: false}, - &cli.StringFlag{Name: "qmc-mmkv", Aliases: []string{"db"}, Usage: "path to qmc mmkv (`.crc` file also required)", Required: false}, + &cli.StringFlag{Name: "qmc-mmkv", Aliases: []string{"db"}, Usage: "path to qmc mmkv (.crc file also required)", Required: false}, &cli.StringFlag{Name: "qmc-mmkv-key", Aliases: []string{"key"}, Usage: "mmkv password (16 ascii chars)", 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}, From c6fa777db1c968cea2c341855c3f49e9665cc2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Wed, 4 Sep 2024 23:06:24 +0100 Subject: [PATCH 4/5] chore: bump version to v0.2.1 --- cmd/um/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/um/main.go b/cmd/um/main.go index 8ba0c1f..29cc9db 100644 --- a/cmd/um/main.go +++ b/cmd/um/main.go @@ -33,7 +33,7 @@ import ( "unlock-music.dev/cli/internal/utils" ) -var AppVersion = "v0.0.6" +var AppVersion = "v0.2.1" var logger, _ = logging.NewZapLogger() // TODO: inject logger to application, instead of using global logger From b3f7cd33dfc3d68b52d34e798ba5d1e87ddae7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Wed, 4 Sep 2024 23:09:43 +0100 Subject: [PATCH 5/5] chore: update vulnerable deps --- go.mod | 6 +++--- go.sum | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a96717c..43d8ab2 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ require ( github.com/samber/lo v1.39.0 github.com/urfave/cli/v2 v2.27.1 go.uber.org/zap v1.27.0 - golang.org/x/crypto v0.22.0 + golang.org/x/crypto v0.26.0 golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f - golang.org/x/text v0.14.0 + golang.org/x/text v0.17.0 unlock-music.dev/mmkv v0.0.0-20240424090133-31549c6a948b ) @@ -21,6 +21,6 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/sys v0.19.0 // indirect + golang.org/x/sys v0.23.0 // indirect google.golang.org/protobuf v1.33.0 // indirect ) diff --git a/go.sum b/go.sum index 5553cc3..fbbdf7c 100644 --- a/go.sum +++ b/go.sum @@ -26,12 +26,18 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=