feat(playlist): download private playlists with arl cookie
This commit is contained in:
+3
-2
@@ -1,3 +1,4 @@
|
||||
license_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
|
||||
license_token = 'AAAAA1bcDFgHJKLmnOPqrsTUvwXYZ12o3lmNOjR2xWiQRT3v5zxL4mKoWjxL82jD7sWx93KfYGsN2IkdPxsUw9PTas7oFbgR3nY9qpZmVyHFJKLPxT7sWmqErXyTn5iKoNpRtV7bPdQZ8qLmWoJpU2nKrXz6vW'
|
||||
arl_cookie = '1d9e90abb452a61b1b7463f0953e1b303c4e2e7e5fd404fde9b385f4de01c340ac0f62f1c8c1550405b0b9beded0e28c481e96a6148e8f4548351add5d7db746b2785ecf83b1768e5dd8cc73b1ad30c18d07c9cb37f5c6b9cd7a78a4de2aff11'
|
||||
secret_key = 'hTv1IAw19qWy9i3f'
|
||||
iv = 'cn1aSvHsV4yBO7x5'
|
||||
iv = '0001020304050607'
|
||||
@@ -71,6 +71,12 @@ func downloadContent(contentType string, args []string) {
|
||||
fmt.Fprintf(os.Stderr, "Error: could not get playlist data: %v\n", err)
|
||||
continue
|
||||
}
|
||||
if playlist.Data.Status == 1 && playlist.Data.CollabKey == "" {
|
||||
fmt.Printf("\r[%d/%d] Getting data for playlist %s... FAILED\n", i+1, nArgs, id)
|
||||
fmt.Fprintf(os.Stderr, "Error: playlist is private and no valid arl cookie was provided\n")
|
||||
continue
|
||||
}
|
||||
|
||||
resource = playlist
|
||||
songs = playlist.GetSongs()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
type Config struct {
|
||||
LicenseToken string `mapstructure:"license_token"`
|
||||
ArlCookie string `mapstructure:"arl_cookie"`
|
||||
SecretKey string `mapstructure:"secret_key"`
|
||||
IV string `mapstructure:"iv"`
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
type Playlist struct {
|
||||
Data struct {
|
||||
Title string `json:"TITLE"`
|
||||
Status int `json:"STATUS"`
|
||||
CollabKey string `json:"COLLAB_KEY"`
|
||||
} `json:"DATA"`
|
||||
Songs struct {
|
||||
Data []*Song `json:"data"`
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/mathismqn/godeez/internal/config"
|
||||
)
|
||||
|
||||
type Resource interface {
|
||||
@@ -18,7 +20,20 @@ type Resource interface {
|
||||
func GetData(r Resource, id string) error {
|
||||
url := r.GetURL(id)
|
||||
|
||||
resp, err := http.Get(url)
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if config.Cfg.ArlCookie != "" {
|
||||
req.AddCookie(&http.Cookie{
|
||||
Name: "arl",
|
||||
Value: config.Cfg.ArlCookie,
|
||||
})
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user