Refactor unrestricting

This commit is contained in:
Ben Sarmiento
2024-04-28 02:38:00 +02:00
parent eb04ed378b
commit 0acb5d9edb
3 changed files with 9 additions and 4 deletions

View File

@@ -69,6 +69,10 @@ func (rd *RealDebrid) UnrestrictCheck(link string) (*Download, error) {
func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Download, error) {
data := url.Values{}
if strings.HasPrefix(link, "https://real-debrid.com/d/") {
// set link to max 39 chars
link = link[0:39]
}
data.Set("link", link)
requestBody := strings.NewReader(data.Encode())
@@ -106,6 +110,7 @@ func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Downloa
return nil, fmt.Errorf("undecodable response: %v", err)
}
// will only check for first byte if serving from rclone
if checkFirstByte && !rd.downloadClient.CanFetchFirstByte(response.Download) {
return nil, fmt.Errorf("can't fetch first byte")
}