Skip to content

Commit

Permalink
Add a default retry to Javlibrary URL requests (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Sep 27, 2020
1 parent 7cc646d commit e33b972
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Javinizer/Public/Get-JavlibraryUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ function Get-JavlibraryUrl {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Performing [GET] on URL [$searchUrl]"
$webRequest = Invoke-WebRequest -Uri $searchUrl -Method Get -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchUrl]: $PSItem" -Action 'Continue'
try {
# Add a retry to the URL search due to 500 errors occurring randomly when scraping Javlibrary
Start-Sleep -Seconds 3
$webRequest = Invoke-WebRequest -Uri $searchUrl -Method Get -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Error occured on [GET] on URL [$searchUrl]: $PSItem" -Action 'Continue'
}
}

# Check if the search uniquely matched a video page
Expand Down

0 comments on commit e33b972

Please sign in to comment.