Skip to content

Commit

Permalink
Update validation flow redundancy (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Oct 11, 2020
1 parent 55a3311 commit 6ea64d6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -508,20 +508,26 @@ function Javinizer {
if (!($CfSession)) {
try {
$CfSession = Get-CfSession -Cfduid:$Settings.'javlibrary.cookie.cfduid' -Cfclearance:$Settings.'javlibrary.cookie.cfclearance' -UserAgent:$Settings.'javlibrary.browser.useragent'
# Testing with the newly created session sometimes fails if there is no wait time
Start-Sleep -Seconds 1
$test = Invoke-WebRequest 'https://www.javlibrary.com' -WebSession $CfSession -UserAgent $CfSession.UserAgent -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($MyInvocation.MyCommand.Name)] Unable reach Javlibrary, enter websession/cookies to use the scraper"
$CfSession = Get-CfSession

# Testing with the newly created session sometimes fails if there is no wait time
Start-Sleep -Seconds 2
Start-Sleep -Seconds 1
try {
$test = Invoke-WebRequest 'https://www.javlibrary.com' -WebSession $CfSession -UserAgent $CfSession.UserAgent -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Unable reach Javlibrary, invalid websession values"
}
}
} else {
try {
$test = Invoke-WebRequest 'https://www.javlibrary.com' -WebSession $CfSession -UserAgent $CfSession.UserAgent -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Unable reach Javlibrary, invalid websession values"
}
}

try {
$test = Invoke-WebRequest 'https://www.javlibrary.com' -WebSession $CfSession -UserAgent $CfSession.UserAgent -Verbose:$false
} catch {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Error -Message "[$($MyInvocation.MyCommand.Name)] Unable reach Javlibrary, invalid websession values"
}

$originalSettingsContent = Get-Content -Path $SettingsPath
Expand Down

0 comments on commit 6ea64d6

Please sign in to comment.