feat(playlist): download private playlists with arl cookie

This commit is contained in:
Mathis Maquenne
2024-10-14 16:22:44 +02:00
parent d38a2c4f7b
commit 6d660e3f51
5 changed files with 29 additions and 4 deletions
+3 -1
View File
@@ -9,7 +9,9 @@ import (
type Playlist struct {
Data struct {
Title string `json:"TITLE"`
Title string `json:"TITLE"`
Status int `json:"STATUS"`
CollabKey string `json:"COLLAB_KEY"`
} `json:"DATA"`
Songs struct {
Data []*Song `json:"data"`
+16 -1
View File
@@ -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
}