@ -27,9 +27,9 @@ namespace NzbDrone.Core.NetImport
public override bool Enabled = > true ;
public override bool Enabled = > true ;
public bool SupportsPaging = > PageSize > 0;
public bool SupportsPaging = > PageSize > 2 0;
public virtual int PageSize = > 0;
public virtual int PageSize = > 2 0;
public virtual TimeSpan RateLimit = > TimeSpan . FromSeconds ( 2 ) ;
public virtual TimeSpan RateLimit = > TimeSpan . FromSeconds ( 2 ) ;
@ -58,13 +58,6 @@ namespace NzbDrone.Core.NetImport
try
try
{
{
var fullyUpdated = false ;
Movie lastMovie = null ;
if ( isRecent )
{
//lastReleaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
}
for ( int i = 0 ; i < pageableRequestChain . Tiers ; i + + )
for ( int i = 0 ; i < pageableRequestChain . Tiers ; i + + )
{
{
var pageableRequests = pageableRequestChain . GetTier ( i ) ;
var pageableRequests = pageableRequestChain . GetTier ( i ) ;
@ -80,37 +73,6 @@ namespace NzbDrone.Core.NetImport
var page = FetchPage ( request , parser ) ;
var page = FetchPage ( request , parser ) ;
pagedReleases . AddRange ( page ) ;
pagedReleases . AddRange ( page ) ;
if ( isRecent & & page . Any ( ) )
{
if ( lastMovie = = null )
{
fullyUpdated = true ;
break ;
} / *
var oldestReleaseDate = page . Select ( v = > v . PublishDate ) . Min ( ) ;
if ( oldestReleaseDate < lastReleaseInfo . PublishDate | | page . Any ( v = > v . DownloadUrl = = lastReleaseInfo . DownloadUrl ) )
{
fullyUpdated = true ;
break ;
}
if ( pagedReleases . Count > = MaxNumResultsPerQuery & &
oldestReleaseDate < DateTime . UtcNow - TimeSpan . FromHours ( 24 ) )
{
fullyUpdated = false ;
break ;
} * ///update later
}
else if ( pagedReleases . Count > = MaxNumResultsPerQuery )
{
break ;
}
if ( ! IsFullPage ( page ) )
{
break ;
}
}
}
movies . AddRange ( pagedReleases ) ;
movies . AddRange ( pagedReleases ) ;
@ -121,29 +83,9 @@ namespace NzbDrone.Core.NetImport
break ;
break ;
}
}
}
}
if ( isRecent & & ! movies . Empty ( ) )
{
var ordered = movies . OrderByDescending ( v = > v . Title ) . ToList ( ) ;
lastMovie = ordered . First ( ) ;
//_indexerStatusService.UpdateRssSyncStatus(Definition.Id, lastReleaseInfo);
}
//_indexerStatusService.RecordSuccess(Definition.Id);
}
}
catch ( WebException webException )
catch ( WebException webException )
{
{
if ( webException . Status = = WebExceptionStatus . NameResolutionFailure | |
webException . Status = = WebExceptionStatus . ConnectFailure )
{
//_indexerStatusService.RecordConnectionFailure(Definition.Id);
}
else
{
//_indexerStatusService.RecordFailure(Definition.Id);
}
if ( webException . Message . Contains ( "502" ) | | webException . Message . Contains ( "503" ) | |
if ( webException . Message . Contains ( "502" ) | | webException . Message . Contains ( "503" ) | |
webException . Message . Contains ( "timed out" ) )
webException . Message . Contains ( "timed out" ) )
{
{
@ -158,28 +100,23 @@ namespace NzbDrone.Core.NetImport
{
{
if ( ( int ) httpException . Response . StatusCode = = 429 )
if ( ( int ) httpException . Response . StatusCode = = 429 )
{
{
//_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
_logger . Warn ( "API Request Limit reached for {0}" , this ) ;
_logger . Warn ( "API Request Limit reached for {0}" , this ) ;
}
}
else
else
{
{
//_indexerStatusService.RecordFailure(Definition.Id);
_logger . Warn ( "{0} {1}" , this , httpException . Message ) ;
_logger . Warn ( "{0} {1}" , this , httpException . Message ) ;
}
}
}
}
catch ( RequestLimitReachedException )
catch ( RequestLimitReachedException )
{
{
//_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
_logger . Warn ( "API Request Limit reached for {0}" , this ) ;
_logger . Warn ( "API Request Limit reached for {0}" , this ) ;
}
}
catch ( ApiKeyException )
catch ( ApiKeyException )
{
{
//_indexerStatusService.RecordFailure(Definition.Id);
_logger . Warn ( "Invalid API Key for {0} {1}" , this , url ) ;
_logger . Warn ( "Invalid API Key for {0} {1}" , this , url ) ;
}
}
catch ( CloudFlareCaptchaException ex )
catch ( CloudFlareCaptchaException ex )
{
{
//_indexerStatusService.RecordFailure(Definition.Id);
if ( ex . IsExpired )
if ( ex . IsExpired )
{
{
_logger . Error ( ex , "Expired CAPTCHA token for {0}, please refresh in indexer settings." , this ) ;
_logger . Error ( ex , "Expired CAPTCHA token for {0}, please refresh in indexer settings." , this ) ;
@ -191,13 +128,11 @@ namespace NzbDrone.Core.NetImport
}
}
catch ( IndexerException ex )
catch ( IndexerException ex )
{
{
//_indexerStatusService.RecordFailure(Definition.Id);
var message = string . Format ( "{0} - {1}" , ex . Message , url ) ;
var message = string . Format ( "{0} - {1}" , ex . Message , url ) ;
_logger . Warn ( ex , message ) ;
_logger . Warn ( ex , message ) ;
}
}
catch ( Exception feedEx )
catch ( Exception feedEx )
{
{
//_indexerStatusService.RecordFailure(Definition.Id);
feedEx . Data . Add ( "FeedUrl" , url ) ;
feedEx . Data . Add ( "FeedUrl" , url ) ;
_logger . Error ( feedEx , "An error occurred while processing feed. " + url ) ;
_logger . Error ( feedEx , "An error occurred while processing feed. " + url ) ;
}
}
@ -205,11 +140,6 @@ namespace NzbDrone.Core.NetImport
return movies ;
return movies ;
}
}
protected virtual bool IsFullPage ( IList < Movie > page )
{
return PageSize ! = 0 & & page . Count > = PageSize ;
}
protected virtual IList < Movie > FetchPage ( NetImportRequest request , IParseNetImportResponse parser )
protected virtual IList < Movie > FetchPage ( NetImportRequest request , IParseNetImportResponse parser )
{
{
var response = FetchIndexerResponse ( request ) ;
var response = FetchIndexerResponse ( request ) ;