@ -24,24 +24,26 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
{
{
var torrentInfos = new List < TorrentInfo > ( ) ;
var torrentInfos = new List < TorrentInfo > ( ) ;
if ( indexerResponse . HttpResponse . StatusCode = = HttpStatusCode . NotFound )
if ( ! indexerResponse . HttpResponse . Headers. ContentType . Contains ( HttpAccept . Json . Value ) )
{
{
return torrentInfos . ToArray ( ) ;
throw new IndexerException ( indexerResponse , $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}" ) ;
}
}
if ( indexerResponse . HttpResponse . StatusCode = = HttpStatusCode . TooManyRequests )
if ( indexerResponse . HttpResponse . StatusCode ! = HttpStatusCode . OK )
{
if ( indexerResponse . HttpResponse . StatusCode = = HttpStatusCode . NotFound )
{
{
throw new RequestLimitReachedException ( indexerResponse , "API Request Limit Reached" ) ;
// No results found
return torrentInfos . ToArray ( ) ;
}
}
if ( indexerResponse . HttpResponse . StatusCode ! = HttpStatusCode . OK )
HttpResponse < AvistazErrorResponse > jsonErrorResponse = new HttpResponse < AvistazErrorResponse > ( indexerResponse . HttpResponse ) ;
if ( indexerResponse . HttpResponse . StatusCode = = HttpStatusCode . Unauthorized )
{
{
throw new IndexerException ( indexerResponse , $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from API request ") ;
throw new IndexerAuthException ( string . Empty , jsonErrorResponse . Resource ? . Message ? ? "Unauthorized request to indexer ") ;
}
}
if ( ! indexerResponse . HttpResponse . Headers . ContentType . Contains ( HttpAccept . Json . Value ) )
throw new IndexerException ( indexerResponse , $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from API request" ) ;
{
throw new IndexerException ( indexerResponse , $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}" ) ;
}
}
var jsonResponse = new HttpResponse < AvistazResponse > ( indexerResponse . HttpResponse ) ;
var jsonResponse = new HttpResponse < AvistazResponse > ( indexerResponse . HttpResponse ) ;