7 Commits

Author SHA1 Message Date
9caf11217b Remove Debug Deps 2021-03-02 18:19:24 +08:00
ef060159f0 Fix #8 2021-03-02 18:16:37 +08:00
939cfd38d0 Fix incorrect package path 2021-03-02 18:16:19 +08:00
379b52295e CI: [GitHub Actions] Build 2021-02-22 00:14:53 +08:00
5f1a30536e README: Add Link to Release 2021-02-22 00:06:31 +08:00
c1b060f363 LICENSE: Say Hello to 2021! 2021-02-22 00:05:37 +08:00
8386fbe23b Fix: Some incorrect file type registration 2021-02-22 00:05:37 +08:00
15 changed files with 91 additions and 58 deletions

52
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,52 @@
name: Build
on:
push:
branches: [ master ]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened ]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
include:
- os: ubuntu-latest
BIN_SUFFIX:
- os: macos-latest
BIN_SUFFIX:
- os: windows-latest
BIN_SUFFIX: .exe
steps:
- name: Checkout codebase
uses: actions/checkout@v2
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
- name: Setup vars
id: vars
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
- name: Build
env:
CGO_ENABLED: 0
run: go build -trimpath -ldflags="-w -s" -v -o um-${{ runner.os }}${{ matrix.BIN_SUFFIX }} ./cmd/um
- name: Publish artifact
uses: actions/upload-artifact@v2
with:
name: um-${{ runner.os }}${{ matrix.BIN_SUFFIX }}
path: ./um-${{ runner.os }}${{ matrix.BIN_SUFFIX }}

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 Unlock Music
Copyright (c) 2020-2021 Unlock Music
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,6 @@
# Unlock Music Project - CLI Edition
Original: Web Edition https://github.com/ix64/unlock-music
- [Release Download](https://github.com/unlock-music/cli/releases/latest)
## Features
- [x] All Algorithm Supported By `ix64/unlock-music`

View File

@ -4,8 +4,8 @@ import (
"bytes"
"encoding/binary"
"errors"
"github.com/umlock-music/cli/algo/common"
"github.com/umlock-music/cli/internal/logging"
"github.com/unlock-music/cli/algo/common"
"github.com/unlock-music/cli/internal/logging"
)
var (

View File

@ -4,7 +4,7 @@ import (
"bytes"
_ "embed"
"github.com/ulikunitz/xz"
"github.com/umlock-music/cli/internal/logging"
"github.com/unlock-music/cli/internal/logging"
"go.uber.org/zap"
"io/ioutil"
)

View File

@ -4,8 +4,7 @@ import (
"bytes"
"encoding/binary"
"errors"
"github.com/davecgh/go-spew/spew"
"github.com/umlock-music/cli/algo/common"
"github.com/unlock-music/cli/algo/common"
"strconv"
"strings"
"unicode"
@ -100,7 +99,6 @@ func (d *Decoder) Decode() error {
d.audio = d.file[1024:]
dataLen := len(d.audio)
spew.Dump(d.audio[:1024])
for i := 0; i < dataLen; i++ {
d.audio[i] ^= d.mask[i&0x1F] //equals: [i % 32]
}

View File

@ -1,7 +1,7 @@
package ncm
import (
"github.com/umlock-music/cli/algo/common"
"github.com/unlock-music/cli/algo/common"
"strings"
)

View File

@ -6,9 +6,9 @@ import (
"encoding/binary"
"encoding/json"
"errors"
"github.com/umlock-music/cli/algo/common"
"github.com/umlock-music/cli/internal/logging"
"github.com/umlock-music/cli/internal/utils"
"github.com/unlock-music/cli/algo/common"
"github.com/unlock-music/cli/internal/logging"
"github.com/unlock-music/cli/internal/utils"
"go.uber.org/zap"
"io/ioutil"
"net/http"
@ -57,10 +57,6 @@ func (d *Decoder) Validate() error {
if !bytes.Equal(magicHeader, d.file[:len(magicHeader)]) {
return errors.New("ncm magic header not match")
}
/*if status.IsDebug {
logging.Log().Info("the unknown field of the header is: \n" + spew.Sdump(d.file[8:10]))
}*/
d.offsetKey = 8 + 2
return nil
}
@ -159,15 +155,6 @@ func (d *Decoder) readCoverData() error {
coverLenStart := d.offsetCover + 5 + 4
bCoverLen := d.file[coverLenStart : coverLenStart+4]
/*if status.IsDebug {
logging.Log().Info("the unknown field of the cover is: \n" +
spew.Sdump(d.file[d.offsetCover:d.offsetCover+5]))
coverLen2 := d.file[d.offsetCover+5 : d.offsetCover+5+4] // it seems that always the same
if !bytes.Equal(coverLen2, bCoverLen) {
logging.Log().Warn("special file found! 2 cover length filed no the same!")
}
}*/
iCoverLen := binary.LittleEndian.Uint32(bCoverLen)
d.offsetAudio = coverLenStart + 4 + iCoverLen
if iCoverLen == 0 {

View File

@ -3,7 +3,7 @@ package qmc
import (
"bytes"
"errors"
"github.com/umlock-music/cli/internal/logging"
"github.com/unlock-music/cli/internal/logging"
"go.uber.org/zap"
)

View File

@ -4,7 +4,7 @@ import (
"encoding/base64"
"encoding/binary"
"errors"
"github.com/umlock-music/cli/algo/common"
"github.com/unlock-music/cli/algo/common"
)
var (
@ -22,11 +22,6 @@ type Decoder struct {
audio []byte
}
//goland:noinspection GoUnusedExportedFunction
func NewDefaultDecoder(data []byte) common.Decoder {
return &Decoder{file: data, mask: getDefaultMask()}
}
func NewMflac256Decoder(data []byte) common.Decoder {
return &Decoder{file: data, maskDetector: detectMflac256Mask, audioExt: "flac"}
}
@ -98,15 +93,20 @@ func (d Decoder) GetMeta() common.Meta {
func DecoderFuncWithExt(ext string) common.NewDecoderFunc {
return func(file []byte) common.Decoder {
return &Decoder{file: file, audioExt: ext}
return &Decoder{file: file, audioExt: ext, mask: getDefaultMask()}
}
}
//goland:noinspection SpellCheckingInspection
func init() {
common.RegisterDecoder("qmc3", DecoderFuncWithExt("mp3")) //QQ Music Mp3
common.RegisterDecoder("qmc2", DecoderFuncWithExt("ogg")) //QQ Music Ogg
common.RegisterDecoder("qmc0", DecoderFuncWithExt("mp3")) //QQ Music Mp3
common.RegisterDecoder("qmc0", DecoderFuncWithExt("mp3")) //QQ Music Mp3
common.RegisterDecoder("qmc3", DecoderFuncWithExt("mp3")) //QQ Music Mp3
common.RegisterDecoder("qmc2", DecoderFuncWithExt("m4a")) //QQ Music M4A
common.RegisterDecoder("qmc4", DecoderFuncWithExt("m4a")) //QQ Music M4A
common.RegisterDecoder("qmc6", DecoderFuncWithExt("m4a")) //QQ Music M4A
common.RegisterDecoder("qmc8", DecoderFuncWithExt("m4a")) //QQ Music M4A
common.RegisterDecoder("qmcflac", DecoderFuncWithExt("flac")) //QQ Music Flac
common.RegisterDecoder("qmcogg", DecoderFuncWithExt("ogg")) //QQ Music Ogg
common.RegisterDecoder("tkm", DecoderFuncWithExt("m4a")) //QQ Music Accompaniment M4a
@ -120,7 +120,6 @@ func init() {
common.RegisterDecoder("6d3461", DecoderFuncWithExt("m4a")) //QQ Music Weiyun M4a
common.RegisterDecoder("776176", DecoderFuncWithExt("wav")) //QQ Music Weiyun Wav
common.RegisterDecoder("mgg", NewMgg256Decoder) //QQ Music Weiyun Wav
common.RegisterDecoder("mflac", NewMflac256Decoder) //QQ Music Weiyun Wav
common.RegisterDecoder("mgg", NewMgg256Decoder) //QQ Music New Ogg
common.RegisterDecoder("mflac", NewMflac256Decoder) //QQ Music New Flac
}

View File

@ -3,7 +3,7 @@ package tm
import (
"bytes"
"errors"
"github.com/umlock-music/cli/algo/common"
"github.com/unlock-music/cli/algo/common"
)
var replaceHeader = []byte{0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70}

View File

@ -3,8 +3,8 @@ package xm
import (
"bytes"
"errors"
"github.com/umlock-music/cli/algo/common"
"github.com/umlock-music/cli/internal/logging"
"github.com/unlock-music/cli/algo/common"
"github.com/unlock-music/cli/internal/logging"
"go.uber.org/zap"
)

View File

@ -2,14 +2,14 @@ package main
import (
"errors"
"github.com/umlock-music/cli/algo/common"
_ "github.com/umlock-music/cli/algo/kgm"
_ "github.com/umlock-music/cli/algo/kwm"
_ "github.com/umlock-music/cli/algo/ncm"
_ "github.com/umlock-music/cli/algo/qmc"
_ "github.com/umlock-music/cli/algo/tm"
_ "github.com/umlock-music/cli/algo/xm"
"github.com/umlock-music/cli/internal/logging"
"github.com/unlock-music/cli/algo/common"
_ "github.com/unlock-music/cli/algo/kgm"
_ "github.com/unlock-music/cli/algo/kwm"
_ "github.com/unlock-music/cli/algo/ncm"
_ "github.com/unlock-music/cli/algo/qmc"
_ "github.com/unlock-music/cli/algo/tm"
_ "github.com/unlock-music/cli/algo/xm"
"github.com/unlock-music/cli/internal/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
"log"

5
go.mod
View File

@ -1,12 +1,11 @@
module github.com/umlock-music/cli
module github.com/unlock-music/cli
go 1.16
require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ulikunitz/xz v0.5.9
github.com/ulikunitz/xz v0.5.10
github.com/urfave/cli/v2 v2.3.0
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0

9
go.sum
View File

@ -1,6 +1,5 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@ -17,18 +16,16 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
@ -61,8 +58,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=