Repair edge cases

This commit is contained in:
Ben Sarmiento
2024-01-19 04:22:56 +01:00
parent 6c7c57ebfa
commit ccd260db6a
5 changed files with 16 additions and 9 deletions

View File

@@ -286,26 +286,26 @@ func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Downloa
resp, err := rd.client.Do(req)
if err != nil {
// rd.log.Errorf("Error when executing the unrestrict link request: %v", err)
return nil, fmt.Errorf("unrestrict link request failed so likely it has expired")
return nil, fmt.Errorf("unrestrict link request failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
rd.log.Errorf("Unrestrict link request returned status code %d for link %s", resp.StatusCode, link)
// return nil, fmt.Errorf("unrestrict link request returned status code %d so likely it has expired", resp.StatusCode)
// return nil, fmt.Errorf("unrestrict link request returned status code %d", resp.StatusCode)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
// rd.log.Errorf("Error when reading the body of unrestrict link response: %v", err)
return nil, fmt.Errorf("unreadable body so likely it has expired")
return nil, fmt.Errorf("unreadable body: %v", err)
}
var response Download
err = json.Unmarshal(body, &response)
if err != nil {
// rd.log.Errorf("Error when decoding unrestrict link JSON: %v", err)
return nil, fmt.Errorf("undecodable response so likely it has expired")
return nil, fmt.Errorf("undecodable response: %v", err)
}
if checkFirstByte && !rd.CanFetchFirstByte(response.Download) {