Set api client token statically, unrestrict client dynamically and download client nothing
This commit is contained in:
@@ -49,8 +49,6 @@ func NewRealDebrid(apiClient, unrestrictClient, downloadClient *zurghttp.HTTPCli
|
||||
log: log,
|
||||
}
|
||||
|
||||
apiClient.SetToken(mainToken)
|
||||
unrestrictClient.SetToken(mainToken)
|
||||
for _, token := range downloadTokens {
|
||||
rd.UnrestrictMap.Set(token, cmap.New[*Download]())
|
||||
}
|
||||
@@ -88,7 +86,7 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
return download, nil
|
||||
}
|
||||
|
||||
download, err := rd.UnrestrictLink(link)
|
||||
download, err := rd.UnrestrictLinkWithToken(link, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -111,7 +109,7 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (rd *RealDebrid) UnrestrictLink(link string) (*Download, error) {
|
||||
func (rd *RealDebrid) UnrestrictLinkWithToken(link, token string) (*Download, error) {
|
||||
data := url.Values{}
|
||||
if strings.HasPrefix(link, "https://real-debrid.com/d/") {
|
||||
// set link to max 39 chars (26 + 13)
|
||||
@@ -126,6 +124,7 @@ func (rd *RealDebrid) UnrestrictLink(link string) (*Download, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
// at this point, any errors mean that the link has expired and we need to repair it
|
||||
|
||||
Reference in New Issue
Block a user