Compare commits

..

No commits in common. "main" and "master" have entirely different histories.
main ... master

11 changed files with 129 additions and 291 deletions

View File

@ -20,11 +20,10 @@ local StepGoBuild(GOOS, GOARCH) = {
local filepath = 'dist/um-%s-%s.tar.gz' % [GOOS, GOARCH], local filepath = 'dist/um-%s-%s.tar.gz' % [GOOS, GOARCH],
name: 'go build %s/%s' % [GOOS, GOARCH], name: 'go build %s/%s' % [GOOS, GOARCH],
image: 'golang:1.22', image: 'golang:1.19',
environment: { environment: {
GOOS: GOOS, GOOS: GOOS,
GOARCH: GOARCH, GOARCH: GOARCH,
GOPROXY: "https://goproxy.io,direct",
}, },
commands: [ commands: [
'DIST_DIR=$(mktemp -d)', 'DIST_DIR=$(mktemp -d)',
@ -40,7 +39,7 @@ local StepUploadArtifact(GOOS, GOARCH) = {
local pkgname = '${DRONE_REPO_NAME}-build', local pkgname = '${DRONE_REPO_NAME}-build',
name: 'upload artifact', name: 'upload artifact',
image: 'golang:1.22', // reuse golang:1.19 for curl image: 'golang:1.19', // reuse golang:1.19 for curl
environment: { environment: {
DRONE_GITEA_SERVER: 'https://git.unlock-music.dev', DRONE_GITEA_SERVER: 'https://git.unlock-music.dev',
GITEA_API_KEY: { from_secret: 'GITEA_API_KEY' }, GITEA_API_KEY: { from_secret: 'GITEA_API_KEY' },
@ -69,10 +68,7 @@ local PipelineBuild(GOOS, GOARCH, RUN_TEST) = {
( (
if RUN_TEST then [{ if RUN_TEST then [{
name: 'go test', name: 'go test',
image: 'golang:1.22', image: 'golang:1.19',
environment: {
GOPROXY: "https://goproxy.io,direct",
},
commands: ['go test -v ./...'], commands: ['go test -v ./...'],
}] else [] }] else []
) )
@ -98,10 +94,7 @@ local PipelineRelease() = {
}, },
{ {
name: 'go test', name: 'go test',
image: 'golang:1.22', image: 'golang:1.19',
environment: {
GOPROXY: "https://goproxy.io,direct",
},
commands: ['go test -v ./...'], commands: ['go test -v ./...'],
}, },
StepGoBuild('linux', 'amd64'), StepGoBuild('linux', 'amd64'),

View File

@ -8,9 +8,7 @@ steps:
name: fetch tags name: fetch tags
- commands: - commands:
- go test -v ./... - go test -v ./...
environment: image: golang:1.19
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go test name: go test
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -21,8 +19,7 @@ steps:
environment: environment:
GOARCH: amd64 GOARCH: amd64
GOOS: linux GOOS: linux
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build linux/amd64 name: go build linux/amd64
- commands: - commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-linux-amd64.tar.gz" - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-linux-amd64.tar.gz"
@ -33,7 +30,7 @@ steps:
DRONE_GITEA_SERVER: https://git.unlock-music.dev DRONE_GITEA_SERVER: https://git.unlock-music.dev
GITEA_API_KEY: GITEA_API_KEY:
from_secret: GITEA_API_KEY from_secret: GITEA_API_KEY
image: golang:1.22 image: golang:1.19
name: upload artifact name: upload artifact
trigger: trigger:
event: event:
@ -57,8 +54,7 @@ steps:
environment: environment:
GOARCH: amd64 GOARCH: amd64
GOOS: windows GOOS: windows
GOPROXY: https://goproxy.io,direct image: golang:1.19
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.tar.gz"
@ -69,7 +65,7 @@ steps:
DRONE_GITEA_SERVER: https://git.unlock-music.dev DRONE_GITEA_SERVER: https://git.unlock-music.dev
GITEA_API_KEY: GITEA_API_KEY:
from_secret: GITEA_API_KEY from_secret: GITEA_API_KEY
image: golang:1.22 image: golang:1.19
name: upload artifact name: upload artifact
trigger: trigger:
event: event:
@ -93,8 +89,7 @@ steps:
environment: environment:
GOARCH: amd64 GOARCH: amd64
GOOS: darwin GOOS: darwin
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build darwin/amd64 name: go build darwin/amd64
- commands: - commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-darwin-amd64.tar.gz" - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-darwin-amd64.tar.gz"
@ -105,7 +100,7 @@ steps:
DRONE_GITEA_SERVER: https://git.unlock-music.dev DRONE_GITEA_SERVER: https://git.unlock-music.dev
GITEA_API_KEY: GITEA_API_KEY:
from_secret: GITEA_API_KEY from_secret: GITEA_API_KEY
image: golang:1.22 image: golang:1.19
name: upload artifact name: upload artifact
trigger: trigger:
event: event:
@ -122,9 +117,7 @@ steps:
name: fetch tags name: fetch tags
- commands: - commands:
- go test -v ./... - go test -v ./...
environment: image: golang:1.19
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go test name: go test
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -135,8 +128,7 @@ steps:
environment: environment:
GOARCH: amd64 GOARCH: amd64
GOOS: linux GOOS: linux
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build linux/amd64 name: go build linux/amd64
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -147,8 +139,7 @@ steps:
environment: environment:
GOARCH: arm64 GOARCH: arm64
GOOS: linux GOOS: linux
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build linux/arm64 name: go build linux/arm64
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -159,8 +150,7 @@ steps:
environment: environment:
GOARCH: "386" GOARCH: "386"
GOOS: linux GOOS: linux
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build linux/386 name: go build linux/386
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -171,8 +161,7 @@ steps:
environment: environment:
GOARCH: amd64 GOARCH: amd64
GOOS: windows GOOS: windows
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build windows/amd64 name: go build windows/amd64
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -183,8 +172,7 @@ steps:
environment: environment:
GOARCH: "386" GOARCH: "386"
GOOS: windows GOOS: windows
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build windows/386 name: go build windows/386
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -195,8 +183,7 @@ steps:
environment: environment:
GOARCH: amd64 GOARCH: amd64
GOOS: darwin GOOS: darwin
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build darwin/amd64 name: go build darwin/amd64
- commands: - commands:
- DIST_DIR=$(mktemp -d) - DIST_DIR=$(mktemp -d)
@ -207,8 +194,7 @@ steps:
environment: environment:
GOARCH: arm64 GOARCH: arm64
GOOS: darwin GOOS: darwin
GOPROXY: https://goproxy.io,direct image: golang:1.19
image: golang:1.22
name: go build darwin/arm64 name: go build darwin/arm64
- image: plugins/gitea-release - image: plugins/gitea-release
name: create release name: create release

View File

@ -18,11 +18,14 @@ type ncmMeta interface {
type ncmMetaMusic struct { type ncmMetaMusic struct {
Format string `json:"format"` Format string `json:"format"`
MusicID int `json:"musicId"`
MusicName string `json:"musicName"` MusicName string `json:"musicName"`
Artist [][]interface{} `json:"artist"` Artist [][]interface{} `json:"artist"`
Album string `json:"album"` Album string `json:"album"`
AlbumID int `json:"albumId"`
AlbumPicDocID interface{} `json:"albumPicDocId"` AlbumPicDocID interface{} `json:"albumPicDocId"`
AlbumPic string `json:"albumPic"` AlbumPic string `json:"albumPic"`
MvID int `json:"mvId"`
Flag int `json:"flag"` Flag int `json:"flag"`
Bitrate int `json:"bitrate"` Bitrate int `json:"bitrate"`
Duration int `json:"duration"` Duration int `json:"duration"`

View File

@ -149,18 +149,12 @@ func (d *Decoder) readMetaData() error {
} }
func (d *Decoder) readCoverData() error { func (d *Decoder) readCoverData() error {
bCoverFrameLen := make([]byte, 4) bCoverCRC := make([]byte, 4)
if _, err := io.ReadFull(d.rd, bCoverFrameLen); err != nil { if _, err := io.ReadFull(d.rd, bCoverCRC); err != nil {
return fmt.Errorf("ncm read cover length: %w", err) return fmt.Errorf("ncm read cover crc: %w", err)
} }
coverFrameStartOffset, err := d.rd.Seek(0, io.SeekCurrent) bCoverLen := make([]byte, 4) //
if err != nil {
return fmt.Errorf("ncm fetch cover frame start offset: %w", err)
}
coverFrameLen := binary.LittleEndian.Uint32(bCoverFrameLen)
bCoverLen := make([]byte, 4)
if _, err := io.ReadFull(d.rd, bCoverLen); err != nil { if _, err := io.ReadFull(d.rd, bCoverLen); err != nil {
return fmt.Errorf("ncm read cover length: %w", err) return fmt.Errorf("ncm read cover length: %w", err)
} }
@ -172,10 +166,7 @@ func (d *Decoder) readCoverData() error {
} }
d.cover = coverBuf d.cover = coverBuf
offsetAudioData := coverFrameStartOffset + int64(coverFrameLen) + 4 return nil
_, err = d.rd.Seek(offsetAudioData, io.SeekStart)
return err
} }
func (d *Decoder) parseMeta() error { func (d *Decoder) parseMeta() error {

View File

@ -80,39 +80,6 @@ func readKeyFromMMKV(file string, logger *zap.Logger) ([]byte, error) {
return deriveKey(buf) return deriveKey(buf)
} }
func OpenMMKV(mmkvPath string, key string, logger *zap.Logger) error {
filePath, fileName := filepath.Split(mmkvPath)
mgr, err := mmkv.NewManager(filepath.Dir(filePath))
if err != nil {
return fmt.Errorf("init mmkv manager: %w", err)
}
// If `vaultKey` is empty, the key is ignored.
streamKeyVault, err = mgr.OpenVaultCrypto(fileName, key)
if err != nil {
return fmt.Errorf("open mmkv vault: %w", err)
}
logger.Debug("mmkv vault opened", zap.Strings("keys", streamKeyVault.Keys()))
return nil
}
// /
func readKeyFromMMKVCustom(mid string) ([]byte, error) {
if streamKeyVault == nil {
return nil, fmt.Errorf("mmkv vault not loaded")
}
// get ekey from mmkv vault
eKey, err := streamKeyVault.GetBytes(mid)
if err != nil {
return nil, fmt.Errorf("get eKey error: %w", err)
}
return deriveKey(eKey)
}
// / getRelativeMMKVDir get mmkv dir relative to file (legacy QQMusic for macOS behaviour)
func getRelativeMMKVDir(file string) (string, error) { func getRelativeMMKVDir(file string) (string, error) {
mmkvDir := filepath.Join(filepath.Dir(file), "../mmkv") mmkvDir := filepath.Join(filepath.Dir(file), "../mmkv")
if _, err := os.Stat(mmkvDir); err != nil { if _, err := os.Stat(mmkvDir); err != nil {
@ -135,7 +102,7 @@ func getDefaultMMKVDir() (string, error) {
mmkvDir := filepath.Join( mmkvDir := filepath.Join(
homeDir, homeDir,
"Library/Containers/com.tencent.QQMusicMac/Data", "Library/Containers/com.tencent.QQMusicMac/Data", // todo: make configurable
"Library/Application Support/QQMusicMac/mmkv", "Library/Application Support/QQMusicMac/mmkv",
) )
if _, err := os.Stat(mmkvDir); err != nil { if _, err := os.Stat(mmkvDir); err != nil {

View File

@ -5,12 +5,13 @@ import (
"encoding/binary" "encoding/binary"
"errors" "errors"
"fmt" "fmt"
"go.uber.org/zap"
"io" "io"
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"go.uber.org/zap"
"unlock-music.dev/cli/algo/common" "unlock-music.dev/cli/algo/common"
"unlock-music.dev/cli/internal/sniff" "unlock-music.dev/cli/internal/sniff"
) )
@ -144,17 +145,6 @@ func (d *Decoder) searchKey() (err error) {
return d.readRawMetaQTag() return d.readRawMetaQTag()
case "STag": case "STag":
return errors.New("qmc: file with 'STag' suffix doesn't contains media key") return errors.New("qmc: file with 'STag' suffix doesn't contains media key")
case "cex\x00":
footer, err := NewMusicExTag(d.raw)
if err != nil {
return err
}
d.audioLen = fileSize - int(footer.TagSize)
d.decodedKey, err = readKeyFromMMKVCustom(footer.MediaFileName)
if err != nil {
return err
}
return nil
default: default:
size := binary.LittleEndian.Uint32(suffixBuf) size := binary.LittleEndian.Uint32(suffixBuf)
@ -254,20 +244,12 @@ func init() {
"6d3461", //QQ Music Weiyun M4a "6d3461", //QQ Music Weiyun M4a
"776176", //QQ Music Weiyun Wav "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 "mmp4", // QQ Music MP4 Container, tipically used for Dolby EAC3 stream
} }
for _, ext := range supportedExts { for _, ext := range supportedExts {
common.RegisterDecoder(ext, false, NewDecoder) 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)
}
}
} }

View File

@ -1,93 +0,0 @@
package qmc
import (
bytes "bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"strings"
)
type MusicExTagV1 struct {
SongID uint32 // Song ID
Unknown1 uint32 // unused & unknown
Unknown2 uint32 // unused & unknown
MediaID string // Media ID
MediaFileName string // real file name
Unknown3 uint32 // unused; uninitialized memory?
// 16 byte at the end of tag.
// TagSize should be respected when parsing.
TagSize uint32 // 19.57: fixed value: 0xC0
TagVersion uint32 // 19.57: fixed value: 0x01
TagMagic []byte // fixed value "musicex\0" (8 bytes)
}
func NewMusicExTag(f io.ReadSeeker) (*MusicExTagV1, error) {
_, err := f.Seek(-16, io.SeekEnd)
if err != nil {
return nil, fmt.Errorf("musicex seek error: %w", err)
}
buffer := make([]byte, 16)
bytesRead, err := f.Read(buffer)
if err != nil {
return nil, fmt.Errorf("get musicex error: %w", err)
}
if bytesRead != 16 {
return nil, fmt.Errorf("MusicExV1: read %d bytes (expected %d)", bytesRead, 16)
}
tag := &MusicExTagV1{
TagSize: binary.LittleEndian.Uint32(buffer[0x00:0x04]),
TagVersion: binary.LittleEndian.Uint32(buffer[0x04:0x08]),
TagMagic: buffer[0x04:0x0C],
}
if !bytes.Equal(tag.TagMagic, []byte("musicex\x00")) {
return nil, errors.New("MusicEx magic mismatch")
}
if tag.TagVersion != 1 {
return nil, errors.New(fmt.Sprintf("unsupported musicex tag version. expecting 1, got %d", tag.TagVersion))
}
if tag.TagSize < 0xC0 {
return nil, errors.New(fmt.Sprintf("unsupported musicex tag size. expecting at least 0xC0, got 0x%02x", tag.TagSize))
}
buffer = make([]byte, tag.TagSize)
bytesRead, err = f.Read(buffer)
if err != nil {
return nil, err
}
if uint32(bytesRead) != tag.TagSize {
return nil, fmt.Errorf("MusicExV1: read %d bytes (expected %d)", bytesRead, tag.TagSize)
}
tag.SongID = binary.LittleEndian.Uint32(buffer[0x00:0x04])
tag.Unknown1 = binary.LittleEndian.Uint32(buffer[0x04:0x08])
tag.Unknown2 = binary.LittleEndian.Uint32(buffer[0x08:0x0C])
tag.MediaID = readUnicodeTagName(buffer[0x0C:], 30*2)
tag.MediaFileName = readUnicodeTagName(buffer[0x48:], 50*2)
tag.Unknown3 = binary.LittleEndian.Uint32(buffer[0xAC:0xB0])
return tag, nil
}
// readUnicodeTagName reads a buffer to maxLen.
// reconstruct text by skipping alternate char (ascii chars encoded in UTF-16-LE),
// until finding a zero or reaching maxLen.
func readUnicodeTagName(buffer []byte, maxLen int) string {
builder := strings.Builder{}
for i := 0; i < maxLen; i += 2 {
chr := buffer[i]
if chr != 0 {
builder.WriteByte(chr)
} else {
break
}
}
return builder.String()
}

View File

@ -23,7 +23,7 @@ import (
_ "unlock-music.dev/cli/algo/kgm" _ "unlock-music.dev/cli/algo/kgm"
_ "unlock-music.dev/cli/algo/kwm" _ "unlock-music.dev/cli/algo/kwm"
_ "unlock-music.dev/cli/algo/ncm" _ "unlock-music.dev/cli/algo/ncm"
"unlock-music.dev/cli/algo/qmc" _ "unlock-music.dev/cli/algo/qmc"
_ "unlock-music.dev/cli/algo/tm" _ "unlock-music.dev/cli/algo/tm"
_ "unlock-music.dev/cli/algo/xiami" _ "unlock-music.dev/cli/algo/xiami"
_ "unlock-music.dev/cli/algo/ximalaya" _ "unlock-music.dev/cli/algo/ximalaya"
@ -33,7 +33,7 @@ import (
"unlock-music.dev/cli/internal/utils" "unlock-music.dev/cli/internal/utils"
) )
var AppVersion = "v0.2.2" var AppVersion = "v0.0.6"
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
@ -50,8 +50,6 @@ func main() {
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: false}, &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: "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-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: "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: "skip-noop", Aliases: []string{"n"}, Usage: "skip noop decoder", Required: false, Value: true},
&cli.BoolFlag{Name: "update-metadata", Usage: "update metadata & album art from network", Required: false, Value: false}, &cli.BoolFlag{Name: "update-metadata", Usage: "update metadata & album art from network", Required: false, Value: false},
@ -132,15 +130,6 @@ func appMain(c *cli.Context) (err error) {
return errors.New("output should be a writable directory") return errors.New("output should be a writable directory")
} }
if mmkv := c.String("qmc-mmkv"); mmkv != "" {
// If key is not set, the mmkv vault will be treated as unencrypted.
key := c.String("qmc-mmkv-key")
err := qmc.OpenMMKV(mmkv, key, logger)
if err != nil {
return err
}
}
proc := &processor{ proc := &processor{
outputDir: output, outputDir: output,
skipNoopDecoder: c.Bool("skip-noop"), skipNoopDecoder: c.Bool("skip-noop"),
@ -254,20 +243,7 @@ func (p *processor) processFile(filePath string) error {
if len(allDec) == 0 { if len(allDec) == 0 {
logger.Fatal("skipping while no suitable decoder") 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 { func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) error {
@ -376,6 +352,8 @@ func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) er
if _, err := io.Copy(outFile, audio); err != nil { if _, err := io.Copy(outFile, audio); err != nil {
return err return err
} }
outFile.Close()
} else { } else {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute) ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel() defer cancel()
@ -385,6 +363,16 @@ func (p *processor) process(inputFile string, allDec []common.NewDecoderFunc) er
} }
} }
logger.Info("successfully converted", zap.String("source", inputFile), zap.String("destination", outPath)) // 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))
}
return nil return nil
} }

34
go.mod
View File

@ -3,24 +3,26 @@ module unlock-music.dev/cli
go 1.19 go 1.19
require ( require (
github.com/fsnotify/fsnotify v1.7.0 github.com/fsnotify/fsnotify v1.6.0
github.com/go-flac/flacpicture v0.3.0 github.com/go-flac/flacpicture v0.2.0
github.com/go-flac/flacvorbis v0.2.0 github.com/go-flac/flacvorbis v0.1.0
github.com/go-flac/go-flac v1.0.0 github.com/go-flac/go-flac v0.3.1
github.com/samber/lo v1.39.0 github.com/samber/lo v1.36.0
github.com/urfave/cli/v2 v2.27.1 github.com/urfave/cli/v2 v2.23.6
go.uber.org/zap v1.27.0 go.uber.org/zap v1.24.0
golang.org/x/crypto v0.26.0 golang.org/x/crypto v0.3.0
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f golang.org/x/exp v0.0.0-20221205204356-47842c84f3db
golang.org/x/text v0.17.0 golang.org/x/text v0.5.0
unlock-music.dev/mmkv v0.0.0-20240424090133-31549c6a948b unlock-music.dev/mmkv v0.0.0-20221204231432-41a75bd29939
) )
require ( require (
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/atomic v1.10.0 // indirect
golang.org/x/sys v0.23.0 // indirect go.uber.org/multierr v1.8.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect golang.org/x/sys v0.2.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
) )

103
go.sum
View File

@ -1,47 +1,66 @@
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/ddliu/go-httpclient v0.5.1 h1:ys4KozrhBaGdI1yuWIFwNNILqhnMU9ozTvRNfCTorvs=
github.com/go-flac/flacpicture v0.3.0 h1:LkmTxzFLIynwfhHiZsX0s8xcr3/u33MzvV89u+zOT8I= github.com/ddliu/go-httpclient v0.5.1/go.mod h1:8QVbjq00YK2f2MQyiKuWMdaKOFRcoD9VuubkNCNOuZo=
github.com/go-flac/flacpicture v0.3.0/go.mod h1:DPbrzVYQ3fJcvSgLFp9HXIrEQEdfdk/+m0nQCzwodZI= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/go-flac/flacvorbis v0.2.0 h1:KH0xjpkNTXFER4cszH4zeJxYcrHbUobz/RticWGOESs= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/go-flac/flacvorbis v0.2.0/go.mod h1:uIysHOtuU7OLGoCRG92bvnkg7QEqHx19qKRV6K1pBrI= github.com/go-flac/flacpicture v0.2.0 h1:rS/ZOR/ZxlEwMf3yOPFcTAmGyoV6rDtcYdd+6CwWQAw=
github.com/go-flac/go-flac v1.0.0 h1:6qI9XOVLcO50xpzm3nXvO31BgDgHhnr/p/rER/K/doY= github.com/go-flac/flacpicture v0.2.0/go.mod h1:M4a1J0v6B5NHsck4GA1yZg0vFQzETVPd3kuj6Ow+q9o=
github.com/go-flac/go-flac v1.0.0/go.mod h1:WnZhcpmq4u1UdZMNn9LYSoASpWOCMOoxXxcWEHSzkW8= github.com/go-flac/flacvorbis v0.1.0 h1:xStJfPrZ/IoA2oBUEwgrlaSf+Opo6/YuQfkqVhkP0cM=
github.com/go-flac/flacvorbis v0.1.0/go.mod h1:70N9vVkQ4Jew0oBWkwqDMIE21h7pMUtQJpnMD0js6XY=
github.com/go-flac/go-flac v0.3.1 h1:BWA7HdO67S4ZLWSVHCxsDHuedFFu5RiV/wmuhvO6Hxo=
github.com/go-flac/go-flac v0.3.1/go.mod h1:jG9IumOfAXr+7J40x0AiQIbJzXf9Y7+Zs/2CNWe4LMk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
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/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/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= github.com/samber/lo v1.36.0 h1:4LaOxH1mHnbDGhTVE0i1z8v/lWaQW8AIfOD3HU4mSaw=
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/samber/lo v1.36.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= github.com/urfave/cli/v2 v2.23.6 h1:iWmtKD+prGo1nKUtLO0Wg4z9esfBM4rAV4QRLQiEmJ4=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= github.com/urfave/cli/v2 v2.23.6/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
unlock-music.dev/mmkv v0.0.0-20240424090133-0953e6901f3a h1:UW0sxgwsfGGC/SrKvvAbZ4HZyOQ3fqs8qr3lBxG6Fzo= unlock-music.dev/mmkv v0.0.0-20221204231432-41a75bd29939 h1:qWv734RbYjIHtHhZSRbdSyAEJ5K1rWcPSuUOen86tvI=
unlock-music.dev/mmkv v0.0.0-20240424090133-0953e6901f3a/go.mod h1:qr34SM3x8xRxyUfGzefH/rSi+DUXkQZcSfXY/yfuTeo= unlock-music.dev/mmkv v0.0.0-20221204231432-41a75bd29939/go.mod h1:1+Hdsrk8gl1i4/oxOnAhx6y51DAcUfi2CDni6Qhk8Kw=
unlock-music.dev/mmkv v0.0.0-20240424090133-31549c6a948b h1:VIJ0mDqj0OgX1ZvL9gbAH8kkqyrDlpVt5yUeGYSJ1/s=
unlock-music.dev/mmkv v0.0.0-20240424090133-31549c6a948b/go.mod h1:qr34SM3x8xRxyUfGzefH/rSi+DUXkQZcSfXY/yfuTeo=

View File

@ -3,7 +3,7 @@ package sniff
// ref: https://mimesniff.spec.whatwg.org // ref: https://mimesniff.spec.whatwg.org
var imageMIMEs = map[string]Sniffer{ var imageMIMEs = map[string]Sniffer{
"image/jpeg": prefixSniffer{0xFF, 0xD8, 0xFF}, "image/jpeg": prefixSniffer{0xFF, 0xD8, 0xFF},
"image/png": prefixSniffer{0x89, 'P', 'N', 'G', '\r', '\n', 0x1A, '\n'}, "image/png": prefixSniffer{'P', 'N', 'G', '\r', '\n', 0x1A, '\n'},
"image/bmp": prefixSniffer("BM"), "image/bmp": prefixSniffer("BM"),
"image/webp": prefixSniffer("RIFF"), "image/webp": prefixSniffer("RIFF"),
"image/gif": prefixSniffer("GIF8"), "image/gif": prefixSniffer("GIF8"),