Skip to content

Commit

Permalink
Update url retrycount to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Dec 13, 2020
1 parent 70cda15 commit a29c166
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Javinizer/Public/Get-Jav321Url.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Get-Jav321Url {
}


$Tries = 5
$Tries = 3
# Get the page search results
$searchResults = $webRequest.Links.OuterHtml | Where-Object { $_ -match 'jav321.com/video/' } |
Select-String -Pattern 'jav321.com/video/(.*)" target' |
Expand Down
36 changes: 21 additions & 15 deletions src/Javinizer/Public/Get-JavbusUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ function Get-JavbusUrl {
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-RestMethod -Uri $searchUrl -Method Get -Verbose:$false
} catch {
try {
Start-Sleep -Seconds 3
$webRequest = Invoke-RestMethod -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'
}
}

$Tries = 5
$retryCount = 3
# Get the page search results
try {
$searchResults = (($webRequest | ForEach-Object { $_ -split '\n' } | Select-String '<a class="movie-box" href="(.*)">').Matches) | ForEach-Object { $_.Groups[1].Value }
Expand All @@ -25,12 +31,12 @@ function Get-JavbusUrl {
}
$numResults = $searchResults.Count

if ($Tries -gt $numResults) {
$Tries = $numResults
if ($retryCount -gt $numResults) {
$retryCount = $numResults
}

if ($numResults -ge 1) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$Tries] of [$numResults] results for [$Id]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$Id]"

$count = 1
foreach ($result in $searchResults) {
Expand All @@ -49,7 +55,7 @@ function Get-JavbusUrl {
break
}

if ($count -eq $Tries) {
if ($count -eq $retryCount) {
break
}

Expand All @@ -65,7 +71,7 @@ function Get-JavbusUrl {
} catch {
}

$Tries = 5
$retryCount = 3
# Get the page search results
try {
$searchResults = (($webRequest | ForEach-Object { $_ -split '\n' } | Select-String '<a class="movie-box" href="(.*)">').Matches) | ForEach-Object { $_.Groups[1].Value }
Expand All @@ -74,12 +80,12 @@ function Get-JavbusUrl {
}
$numResults = $searchResults.Count

if ($Tries -gt $numResults) {
$Tries = $numResults
if ($retryCount -gt $numResults) {
$retryCount = $numResults
}

if ($numResults -ge 1) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$Tries] of [$numResults] results for [$Id]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$Id]"

$count = 1
foreach ($result in $searchResults) {
Expand All @@ -98,7 +104,7 @@ function Get-JavbusUrl {
break
}

if ($count -eq $Tries) {
if ($count -eq $retryCount) {
break
}

Expand All @@ -115,7 +121,7 @@ function Get-JavbusUrl {
} catch {
}

$Tries = 5
$retryCount = 3
# Get the page search results
try {
$searchResults = (($webRequest | ForEach-Object { $_ -split '\n' } | Select-String '<a class="movie-box" href="(.*)">').Matches) | ForEach-Object { $_.Groups[1].Value }
Expand All @@ -124,12 +130,12 @@ function Get-JavbusUrl {
}
$numResults = $searchResults.Count

if ($Tries -gt $numResults) {
$Tries = $numResults
if ($retryCount -gt $numResults) {
$retryCount = $numResults
}

if ($numResults -ge 1) {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$Tries] of [$numResults] results for [$Id]"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Debug -Message "[$Id] [$($MyInvocation.MyCommand.Name)] Searching [$retryCount] of [$numResults] results for [$Id]"

$count = 1
foreach ($result in $searchResults) {
Expand All @@ -148,7 +154,7 @@ function Get-JavbusUrl {
break
}

if ($count -eq $Tries) {
if ($count -eq $retryCount) {
break
}

Expand Down
8 changes: 4 additions & 4 deletions src/Javinizer/Public/Get-JavlibraryUrl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ function Get-JavlibraryUrl {
}

if ($null -eq $javlibraryUrl) {
$Tries = 5
$retryCount = 3
$searchResults = $webRequest.Links.href | Where-Object { $_ -match '\.\/\?v=(.*)' }
$numResults = $searchResults.count

if ($Tries -gt $numResults) {
$Tries = $numResults
if ($retryCount -gt $numResults) {
$retryCount = $numResults
}

if ($numResults -ge 1) {
Expand All @@ -82,7 +82,7 @@ function Get-JavlibraryUrl {
break
}

if ($count -eq $Tries) {
if ($count -eq $retryCount) {
break
}

Expand Down

0 comments on commit a29c166

Please sign in to comment.