Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
1760737121 | |||
b517806fdb | |||
b6df09cee3 | |||
9cf42af251 | |||
c1c43d2a41 | |||
f9686bbfc4 | |||
9caf11217b | |||
ef060159f0 | |||
939cfd38d0 | |||
379b52295e | |||
5f1a30536e | |||
c1b060f363 | |||
8386fbe23b |
57
.github/workflows/build.yml
vendored
Normal file
57
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
paths:
|
||||||
|
- "**/*.go"
|
||||||
|
- "go.mod"
|
||||||
|
- "go.sum"
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
|
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
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- 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)"
|
||||||
|
echo "::set-output name=git_tag::$(git describe --tags --always)"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
run: go build -trimpath -ldflags="-w -s -X main.AppVersion=${{ steps.vars.outputs.git_tag }}" -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 }}
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Unlock Music Project - CLI Edition
|
# Unlock Music Project - CLI Edition
|
||||||
Original: Web Edition https://github.com/ix64/unlock-music
|
Original: Web Edition https://github.com/ix64/unlock-music
|
||||||
|
- [Release Download](https://github.com/unlock-music/cli/releases/latest)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- [x] All Algorithm Supported By `ix64/unlock-music`
|
- [x] All Algorithm Supported By `ix64/unlock-music`
|
||||||
|
@ -27,7 +27,7 @@ func (d RawDecoder) GetAudioData() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d RawDecoder) GetAudioExt() string {
|
func (d RawDecoder) GetAudioExt() string {
|
||||||
return d.audioExt
|
return "." + d.audioExt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d RawDecoder) GetMeta() Meta {
|
func (d RawDecoder) GetMeta() Meta {
|
||||||
|
44
algo/common/sniff.go
Normal file
44
algo/common/sniff.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import "bytes"
|
||||||
|
|
||||||
|
type Sniffer func(header []byte) bool
|
||||||
|
|
||||||
|
var snifferRegistry = map[string]Sniffer{
|
||||||
|
".m4a": SnifferM4A,
|
||||||
|
".ogg": SnifferOGG,
|
||||||
|
".flac": SnifferFLAC,
|
||||||
|
".wav": SnifferWAV,
|
||||||
|
".wma": SnifferWMA,
|
||||||
|
".mp3": SnifferMP3,
|
||||||
|
}
|
||||||
|
|
||||||
|
func SniffAll(header []byte) (string, bool) {
|
||||||
|
for ext, sniffer := range snifferRegistry {
|
||||||
|
if sniffer(header) {
|
||||||
|
return ext, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
func SnifferM4A(header []byte) bool {
|
||||||
|
return len(header) >= 8 && bytes.Equal([]byte("ftyp"), header[4:8])
|
||||||
|
}
|
||||||
|
|
||||||
|
func SnifferOGG(header []byte) bool {
|
||||||
|
return bytes.HasPrefix(header, []byte("OggS"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func SnifferFLAC(header []byte) bool {
|
||||||
|
return bytes.HasPrefix(header, []byte("fLaC"))
|
||||||
|
}
|
||||||
|
func SnifferMP3(header []byte) bool {
|
||||||
|
return bytes.HasPrefix(header, []byte("ID3"))
|
||||||
|
}
|
||||||
|
func SnifferWAV(header []byte) bool {
|
||||||
|
return bytes.HasPrefix(header, []byte("RIFF"))
|
||||||
|
}
|
||||||
|
func SnifferWMA(header []byte) bool {
|
||||||
|
return bytes.HasPrefix(header, []byte("\x30\x26\xb2\x75\x8e\x66\xcf\x11\xa6\xd9\x00\xaa\x00\x62\xce\x6c"))
|
||||||
|
}
|
@ -4,8 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/umlock-music/cli/algo/common"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
"github.com/umlock-music/cli/internal/logging"
|
"github.com/unlock-music/cli/internal/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"github.com/ulikunitz/xz"
|
"github.com/ulikunitz/xz"
|
||||||
"github.com/umlock-music/cli/internal/logging"
|
"github.com/unlock-music/cli/internal/logging"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
@ -4,8 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
"github.com/umlock-music/cli/algo/common"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
@ -41,7 +40,7 @@ func (d *Decoder) GetAudioData() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Decoder) GetAudioExt() string {
|
func (d *Decoder) GetAudioExt() string {
|
||||||
return d.outputExt
|
return "." + d.outputExt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Decoder) GetMeta() common.Meta {
|
func (d *Decoder) GetMeta() common.Meta {
|
||||||
@ -100,7 +99,6 @@ func (d *Decoder) Decode() error {
|
|||||||
|
|
||||||
d.audio = d.file[1024:]
|
d.audio = d.file[1024:]
|
||||||
dataLen := len(d.audio)
|
dataLen := len(d.audio)
|
||||||
spew.Dump(d.audio[:1024])
|
|
||||||
for i := 0; i < dataLen; i++ {
|
for i := 0; i < dataLen; i++ {
|
||||||
d.audio[i] ^= d.mask[i&0x1F] //equals: [i % 32]
|
d.audio[i] ^= d.mask[i&0x1F] //equals: [i % 32]
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ncm
|
package ncm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/umlock-music/cli/algo/common"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/umlock-music/cli/algo/common"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
"github.com/umlock-music/cli/internal/logging"
|
"github.com/unlock-music/cli/internal/logging"
|
||||||
"github.com/umlock-music/cli/internal/utils"
|
"github.com/unlock-music/cli/internal/utils"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -57,10 +57,6 @@ func (d *Decoder) Validate() error {
|
|||||||
if !bytes.Equal(magicHeader, d.file[:len(magicHeader)]) {
|
if !bytes.Equal(magicHeader, d.file[:len(magicHeader)]) {
|
||||||
return errors.New("ncm magic header not match")
|
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
|
d.offsetKey = 8 + 2
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -159,15 +155,6 @@ func (d *Decoder) readCoverData() error {
|
|||||||
coverLenStart := d.offsetCover + 5 + 4
|
coverLenStart := d.offsetCover + 5 + 4
|
||||||
bCoverLen := d.file[coverLenStart : coverLenStart+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)
|
iCoverLen := binary.LittleEndian.Uint32(bCoverLen)
|
||||||
d.offsetAudio = coverLenStart + 4 + iCoverLen
|
d.offsetAudio = coverLenStart + 4 + iCoverLen
|
||||||
if iCoverLen == 0 {
|
if iCoverLen == 0 {
|
||||||
@ -214,7 +201,9 @@ func (d *Decoder) Decode() error {
|
|||||||
|
|
||||||
func (d Decoder) GetAudioExt() string {
|
func (d Decoder) GetAudioExt() string {
|
||||||
if d.meta != nil {
|
if d.meta != nil {
|
||||||
return d.meta.GetFormat()
|
if format := d.meta.GetFormat(); format != "" {
|
||||||
|
return "." + d.meta.GetFormat()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,6 @@ var (
|
|||||||
0x92, 0x62, 0xf3, 0x74, 0xa1, 0x9f, 0xf4, 0xa0,
|
0x92, 0x62, 0xf3, 0x74, 0xa1, 0x9f, 0xf4, 0xa0,
|
||||||
0x1d, 0x3f, 0x5b, 0xf0, 0x13, 0x0e, 0x09, 0x3d,
|
0x1d, 0x3f, 0x5b, 0xf0, 0x13, 0x0e, 0x09, 0x3d,
|
||||||
0xf9, 0xbc, 0x00, 0x11}
|
0xf9, 0xbc, 0x00, 0x11}
|
||||||
headerFlac = []byte{'f', 'L', 'a', 'C'}
|
|
||||||
headerOgg = []byte{'O', 'g', 'g', 'S'}
|
|
||||||
)
|
)
|
||||||
var key256MappingAll [][]int //[idx256][idx128]idx44
|
var key256MappingAll [][]int //[idx256][idx128]idx44
|
||||||
var key256Mapping128to44 map[int]int
|
var key256Mapping128to44 map[int]int
|
||||||
|
@ -3,7 +3,8 @@ package qmc
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"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"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ func detectMflac256Mask(input []byte) (*Key256Mask, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if bytes.Equal(headerFlac, q.Decrypt(input[:len(headerFlac)])) {
|
if common.SnifferFLAC(q.Decrypt(input[:4])) {
|
||||||
rtErr = nil
|
rtErr = nil
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -164,7 +165,7 @@ func detectMgg256Mask(input []byte) (*Key256Mask, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if bytes.Equal(headerOgg, q.Decrypt(input[:len(headerOgg)])) {
|
if common.SnifferOGG(q.Decrypt(input[:4])) {
|
||||||
return q, nil
|
return q, nil
|
||||||
}
|
}
|
||||||
return nil, ErrDetectMggMask
|
return nil, ErrDetectMggMask
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/umlock-music/cli/algo/common"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -22,11 +22,6 @@ type Decoder struct {
|
|||||||
audio []byte
|
audio []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
//goland:noinspection GoUnusedExportedFunction
|
|
||||||
func NewDefaultDecoder(data []byte) common.Decoder {
|
|
||||||
return &Decoder{file: data, mask: getDefaultMask()}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMflac256Decoder(data []byte) common.Decoder {
|
func NewMflac256Decoder(data []byte) common.Decoder {
|
||||||
return &Decoder{file: data, maskDetector: detectMflac256Mask, audioExt: "flac"}
|
return &Decoder{file: data, maskDetector: detectMflac256Mask, audioExt: "flac"}
|
||||||
}
|
}
|
||||||
@ -89,7 +84,10 @@ func (d Decoder) GetAudioData() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d Decoder) GetAudioExt() string {
|
func (d Decoder) GetAudioExt() string {
|
||||||
return d.audioExt
|
if d.audioExt != "" {
|
||||||
|
return "." + d.audioExt
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Decoder) GetMeta() common.Meta {
|
func (d Decoder) GetMeta() common.Meta {
|
||||||
@ -98,15 +96,20 @@ func (d Decoder) GetMeta() common.Meta {
|
|||||||
|
|
||||||
func DecoderFuncWithExt(ext string) common.NewDecoderFunc {
|
func DecoderFuncWithExt(ext string) common.NewDecoderFunc {
|
||||||
return func(file []byte) common.Decoder {
|
return func(file []byte) common.Decoder {
|
||||||
return &Decoder{file: file, audioExt: ext}
|
return &Decoder{file: file, audioExt: ext, mask: getDefaultMask()}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//goland:noinspection SpellCheckingInspection
|
//goland:noinspection SpellCheckingInspection
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisterDecoder("qmc3", DecoderFuncWithExt("mp3")) //QQ Music Mp3
|
common.RegisterDecoder("qmc0", DecoderFuncWithExt("mp3")) //QQ Music Mp3
|
||||||
common.RegisterDecoder("qmc2", DecoderFuncWithExt("ogg")) //QQ Music Ogg
|
common.RegisterDecoder("qmc3", DecoderFuncWithExt("mp3")) //QQ Music Mp3
|
||||||
common.RegisterDecoder("qmc0", 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("qmcflac", DecoderFuncWithExt("flac")) //QQ Music Flac
|
||||||
common.RegisterDecoder("qmcogg", DecoderFuncWithExt("ogg")) //QQ Music Ogg
|
common.RegisterDecoder("qmcogg", DecoderFuncWithExt("ogg")) //QQ Music Ogg
|
||||||
common.RegisterDecoder("tkm", DecoderFuncWithExt("m4a")) //QQ Music Accompaniment M4a
|
common.RegisterDecoder("tkm", DecoderFuncWithExt("m4a")) //QQ Music Accompaniment M4a
|
||||||
@ -120,7 +123,6 @@ func init() {
|
|||||||
common.RegisterDecoder("6d3461", DecoderFuncWithExt("m4a")) //QQ Music Weiyun M4a
|
common.RegisterDecoder("6d3461", DecoderFuncWithExt("m4a")) //QQ Music Weiyun M4a
|
||||||
common.RegisterDecoder("776176", DecoderFuncWithExt("wav")) //QQ Music Weiyun Wav
|
common.RegisterDecoder("776176", DecoderFuncWithExt("wav")) //QQ Music Weiyun Wav
|
||||||
|
|
||||||
common.RegisterDecoder("mgg", NewMgg256Decoder) //QQ Music Weiyun Wav
|
common.RegisterDecoder("mgg", NewMgg256Decoder) //QQ Music New Ogg
|
||||||
common.RegisterDecoder("mflac", NewMflac256Decoder) //QQ Music Weiyun Wav
|
common.RegisterDecoder("mflac", NewMflac256Decoder) //QQ Music New Flac
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package tm
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"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}
|
var replaceHeader = []byte{0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70}
|
||||||
@ -25,7 +25,10 @@ func (d *Decoder) GetAudioData() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Decoder) GetAudioExt() string {
|
func (d *Decoder) GetAudioExt() string {
|
||||||
return d.audioExt
|
if d.audioExt != "" {
|
||||||
|
return "." + d.audioExt
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Decoder) GetMeta() common.Meta {
|
func (d *Decoder) GetMeta() common.Meta {
|
||||||
|
@ -3,8 +3,8 @@ package xm
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/umlock-music/cli/algo/common"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
"github.com/umlock-music/cli/internal/logging"
|
"github.com/unlock-music/cli/internal/logging"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,7 +38,11 @@ func (d *Decoder) GetAudioData() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Decoder) GetAudioExt() string {
|
func (d *Decoder) GetAudioExt() string {
|
||||||
return d.outputExt
|
if d.outputExt != "" {
|
||||||
|
return "." + d.outputExt
|
||||||
|
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Decoder) GetMeta() common.Meta {
|
func (d *Decoder) GetMeta() common.Meta {
|
||||||
|
@ -2,14 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/umlock-music/cli/algo/common"
|
"github.com/unlock-music/cli/algo/common"
|
||||||
_ "github.com/umlock-music/cli/algo/kgm"
|
_ "github.com/unlock-music/cli/algo/kgm"
|
||||||
_ "github.com/umlock-music/cli/algo/kwm"
|
_ "github.com/unlock-music/cli/algo/kwm"
|
||||||
_ "github.com/umlock-music/cli/algo/ncm"
|
_ "github.com/unlock-music/cli/algo/ncm"
|
||||||
_ "github.com/umlock-music/cli/algo/qmc"
|
_ "github.com/unlock-music/cli/algo/qmc"
|
||||||
_ "github.com/umlock-music/cli/algo/tm"
|
_ "github.com/unlock-music/cli/algo/tm"
|
||||||
_ "github.com/umlock-music/cli/algo/xm"
|
_ "github.com/unlock-music/cli/algo/xm"
|
||||||
"github.com/umlock-music/cli/internal/logging"
|
"github.com/unlock-music/cli/internal/logging"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"log"
|
"log"
|
||||||
@ -18,12 +18,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var AppVersion = "0.0.3"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.App{
|
app := cli.App{
|
||||||
Name: "Unlock Music CLI",
|
Name: "Unlock Music CLI",
|
||||||
HelpName: "um",
|
HelpName: "um",
|
||||||
Usage: "Unlock your encrypted music file https://github.com/unlock-music/cli",
|
Usage: "Unlock your encrypted music file https://github.com/unlock-music/cli",
|
||||||
Version: "v0.0.1",
|
Version: AppVersion,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: true},
|
&cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: true},
|
||||||
&cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "path to output dir", Required: true},
|
&cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "path to output dir", Required: true},
|
||||||
@ -117,14 +119,19 @@ func tryDecFile(inputFile string, outputDir string, allDec []common.NewDecoderFu
|
|||||||
return errors.New("failed while decoding: " + err.Error())
|
return errors.New("failed while decoding: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outData := dec.GetAudioData()
|
||||||
outExt := dec.GetAudioExt()
|
outExt := dec.GetAudioExt()
|
||||||
if outExt == "" {
|
if outExt == "" {
|
||||||
outExt = "mp3"
|
if ext, ok := common.SniffAll(outData); ok {
|
||||||
|
outExt = ext
|
||||||
|
} else {
|
||||||
|
outExt = ".mp3"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
filenameOnly := strings.TrimSuffix(filepath.Base(inputFile), filepath.Ext(inputFile))
|
filenameOnly := strings.TrimSuffix(filepath.Base(inputFile), filepath.Ext(inputFile))
|
||||||
|
|
||||||
outPath := filepath.Join(outputDir, filenameOnly+"."+outExt)
|
outPath := filepath.Join(outputDir, filenameOnly+outExt)
|
||||||
err = os.WriteFile(outPath, dec.GetAudioData(), 0644)
|
err = os.WriteFile(outPath, outData, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
5
go.mod
5
go.mod
@ -1,12 +1,11 @@
|
|||||||
module github.com/umlock-music/cli
|
module github.com/unlock-music/cli
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
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/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
|
github.com/urfave/cli/v2 v2.3.0
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
go.uber.org/multierr v1.6.0 // indirect
|
||||||
go.uber.org/zap v1.16.0
|
go.uber.org/zap v1.16.0
|
||||||
|
9
go.sum
9
go.sum
@ -1,6 +1,5 @@
|
|||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
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-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 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
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/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.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 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
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/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/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.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
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.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
|
||||||
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
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 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
||||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
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 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/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/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.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=
|
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 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
Reference in New Issue
Block a user