Hotfix
This commit is contained in:
@@ -19,7 +19,7 @@ type RealDebrid struct {
|
||||
client *zurghttp.HTTPClient
|
||||
}
|
||||
|
||||
func NewRealDebrid(accessToken string, client *zurghttp.HTTPClient, log *zap.SugaredLogger) *RealDebrid {
|
||||
func NewRealDebrid(client *zurghttp.HTTPClient, log *zap.SugaredLogger) *RealDebrid {
|
||||
return &RealDebrid{
|
||||
log: log,
|
||||
client: client,
|
||||
@@ -69,7 +69,7 @@ func (rd *RealDebrid) GetTorrents(customLimit int) ([]Torrent, int, error) {
|
||||
page := 1
|
||||
limit := customLimit
|
||||
if limit == 0 {
|
||||
limit = 2500
|
||||
limit = 1000
|
||||
}
|
||||
totalCount := 0
|
||||
|
||||
@@ -263,7 +263,7 @@ func (rd *RealDebrid) GetActiveTorrentCount() (*ActiveTorrentCountResponse, erro
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
func (rd *RealDebrid) UnrestrictLink(link string) (*UnrestrictResponse, error) {
|
||||
func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*UnrestrictResponse, error) {
|
||||
data := url.Values{}
|
||||
data.Set("link", link)
|
||||
|
||||
@@ -283,6 +283,11 @@ func (rd *RealDebrid) UnrestrictLink(link string) (*UnrestrictResponse, error) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
// rd.log.Errorf("Error when reading the body of unrestrict link response: %v", err)
|
||||
@@ -296,7 +301,7 @@ func (rd *RealDebrid) UnrestrictLink(link string) (*UnrestrictResponse, error) {
|
||||
return nil, fmt.Errorf("undecodable response so likely it has expired")
|
||||
}
|
||||
|
||||
if !rd.canFetchFirstByte(response.Download) {
|
||||
if checkFirstByte && !rd.canFetchFirstByte(response.Download) {
|
||||
return nil, fmt.Errorf("can't fetch first byte")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user