feat(cli): add config flag
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package config
|
||||
|
||||
type Config struct {
|
||||
LicenseToken string `mapstructure:"license_token"`
|
||||
SecretKey string `mapstructure:"secret_key"`
|
||||
IV string `mapstructure:"iv"`
|
||||
}
|
||||
|
||||
var Cfg Config
|
||||
@@ -3,21 +3,18 @@ package crypto
|
||||
import (
|
||||
"crypto/cipher"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/mathismqn/godeez/internal/config"
|
||||
"golang.org/x/crypto/blowfish"
|
||||
)
|
||||
|
||||
const (
|
||||
SecretKey = ""
|
||||
IV = ""
|
||||
)
|
||||
|
||||
func GetBlowfishKey(songID string) []byte {
|
||||
hash := md5.Sum([]byte(songID))
|
||||
hashHex := fmt.Sprintf("%x", hash)
|
||||
|
||||
key := []byte(SecretKey)
|
||||
key := []byte(config.Cfg.SecretKey)
|
||||
for i := 0; i < len(hash); i++ {
|
||||
key[i] = key[i] ^ hashHex[i] ^ hashHex[i+16]
|
||||
}
|
||||
@@ -31,7 +28,12 @@ func DecryptBlowfish(data, key []byte) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mode := cipher.NewCBCDecrypter(block, []byte(IV))
|
||||
iv, err := hex.DecodeString(config.Cfg.IV)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mode := cipher.NewCBCDecrypter(block, iv)
|
||||
decrypted := make([]byte, len(data))
|
||||
mode.CryptBlocks(decrypted, data)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/mathismqn/godeez/internal/config"
|
||||
)
|
||||
|
||||
type Song struct {
|
||||
@@ -16,10 +18,8 @@ type Song struct {
|
||||
TrackToken string `json:"TRACK_TOKEN"`
|
||||
}
|
||||
|
||||
const LicenseToken = ""
|
||||
|
||||
func (s *Song) GetMediaData() (*Media, error) {
|
||||
reqBody := fmt.Sprintf(`{"license_token":"%s","media":[{"type":"FULL","formats":[{"cipher":"BF_CBC_STRIPE","format":"FLAC"}]}],"track_tokens":["%s"]}`, LicenseToken, s.TrackToken)
|
||||
reqBody := fmt.Sprintf(`{"license_token":"%s","media":[{"type":"FULL","formats":[{"cipher":"BF_CBC_STRIPE","format":"FLAC"}]}],"track_tokens":["%s"]}`, config.Cfg.LicenseToken, s.TrackToken)
|
||||
|
||||
resp, err := http.Post("https://media.deezer.com/v1/get_url", "application/json", bytes.NewBuffer([]byte(reqBody)))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user