mark as unplayable and availability check
This commit is contained in:
@@ -390,3 +390,35 @@ func (rd *RealDebrid) GetUserInformation() (*User, error) {
|
||||
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
// AvailabilityCheck checks the instant availability of torrents
|
||||
func (rd *RealDebrid) AvailabilityCheck(hashes []string) (AvailabilityResponse, error) {
|
||||
if len(hashes) == 0 {
|
||||
return nil, fmt.Errorf("no hashes provided")
|
||||
}
|
||||
|
||||
baseURL := "https://api.real-debrid.com/rest/1.0"
|
||||
url := fmt.Sprintf("%s/torrents/instantAvailability/%s", baseURL, strings.Join(hashes, "/"))
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := rd.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("error, got response status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
var response AvailabilityResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user