feat: first version of kgg support

This commit is contained in:
鲁树人
2025-05-07 07:57:40 +09:00
parent 380ed78b6b
commit 006bad8c48
11 changed files with 425 additions and 45 deletions

View File

@@ -14,10 +14,12 @@ type Decoder struct {
offset int
header header
KggDatabasePath string
}
func NewDecoder(p *common.DecoderParams) common.Decoder {
return &Decoder{rd: p.Reader}
return &Decoder{rd: p.Reader, KggDatabasePath: p.KggDatabasePath}
}
// Validate checks if the file is a valid Kugou (.kgm, .vpr, .kgma) file.
@@ -34,6 +36,11 @@ func (d *Decoder) Validate() (err error) {
if err != nil {
return fmt.Errorf("kgm init crypto v3: %w", err)
}
case 5:
d.cipher, err = newKgmCryptoV5(&d.header, d.KggDatabasePath)
if err != nil {
return fmt.Errorf("kgm init crypto v5: %w", err)
}
default:
return fmt.Errorf("kgm: unsupported crypto version %d", d.header.CryptoVersion)
}
@@ -57,6 +64,7 @@ func (d *Decoder) Read(buf []byte) (int, error) {
func init() {
// Kugou
common.RegisterDecoder("kgg", false, NewDecoder)
common.RegisterDecoder("kgm", false, NewDecoder)
common.RegisterDecoder("kgma", false, NewDecoder)
// Viper