mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
implement native Deezer download/decrypt pipeline
Replace Deezer yt-dlp usage with native ARL session + media.get_url resolution, add BF_CBC_STRIPE decryption in downloader, and wire cipher-aware Deezer downloads through the main rip pipeline. Includes validation hardening and metadata/source-id improvements used by tagging flows.
This commit is contained in:
@@ -2,11 +2,14 @@ package download
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/cipher"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/crypto/blowfish"
|
||||
)
|
||||
|
||||
func TestDownloaderHasNoClientTimeout(t *testing.T) {
|
||||
@@ -51,3 +54,33 @@ func TestManifestDetection(t *testing.T) {
|
||||
t.Fatalf("did not expect flac to be manifest")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDeezerTrackID(t *testing.T) {
|
||||
if got := normalizeDeezerTrackID("https://www.deezer.com/track/3135556"); got != "3135556" {
|
||||
t.Fatalf("normalize track id = %q, want 3135556", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecryptDeezerBFCBCStripe(t *testing.T) {
|
||||
trackID := "3135556"
|
||||
plain := make([]byte, deezerBFChunkSize*2)
|
||||
for i := range plain {
|
||||
plain[i] = byte(i % 251)
|
||||
}
|
||||
enc := make([]byte, len(plain))
|
||||
copy(enc, plain)
|
||||
block, err := blowfish.NewCipher(deriveDeezerBlowfishKey(trackID))
|
||||
if err != nil {
|
||||
t.Fatalf("cipher error: %v", err)
|
||||
}
|
||||
cbc := cipher.NewCBCEncrypter(block, deezerBFIV)
|
||||
cbc.CryptBlocks(enc[:deezerBFChunkSize], enc[:deezerBFChunkSize])
|
||||
|
||||
dec, err := decryptDeezerBFCBCStripe(enc, trackID)
|
||||
if err != nil {
|
||||
t.Fatalf("decrypt error: %v", err)
|
||||
}
|
||||
if len(dec) != len(plain) || string(dec) != string(plain) {
|
||||
t.Fatalf("decrypted data mismatch")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user