-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
297 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,48 @@ | ||
function Set-JavlibraryOwned { | ||
[CmdletBinding()] | ||
param ( | ||
[object]$AjaxId, | ||
[object]$JavlibraryUrl, | ||
[object]$Settings | ||
) | ||
|
||
Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function started" | ||
Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] AjaxId: $AjaxId" | ||
Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Url: $JavlibraryUrl" | ||
|
||
try { | ||
$timeout = New-TimeSpan -Seconds $Settings.JavLibrary.'request-timeout-sec' | ||
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew() | ||
while ($check.content -notmatch '"ERROR":1' -and $stopwatch.elapsed -lt $timeout) { | ||
if ($check.Content -match '"ERROR":-3') { | ||
Start-Sleep -Seconds 3 | ||
process { | ||
try { | ||
$timeout = New-TimeSpan -Seconds $Settings.JavLibrary.'request-timeout-sec' | ||
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew() | ||
while ($check.content -notmatch '"ERROR":1' -and $stopwatch.elapsed -lt $timeout) { | ||
if ($check.Content -match '"ERROR":-3') { | ||
Start-Sleep -Seconds 3 | ||
} | ||
$check = Invoke-WebRequest -Uri "https://www.javlibrary.com/ajax/ajax_cv_favoriteadd.php" ` | ||
-Method "POST" ` | ||
-Headers @{ | ||
"method" = "POST" | ||
"authority" = "www.javlibrary.com" | ||
"scheme" = "https" | ||
"path" = "/ajax/ajax_cv_favoriteadd.php" | ||
"accept" = "application/json, text/javascript, */*; q=0.01" | ||
"x-requested-with" = "XMLHttpRequest" | ||
"user-agent" = $session.UserAgent | ||
"origin" = "https://www.javlibrary.com" | ||
"sec-fetch-site" = "same-origin" | ||
"sec-fetch-mode" = "cors" | ||
"sec-fetch-dest" = "empty" | ||
"referer" = $JavlibraryUrl | ||
"accept-encoding" = "gzip, deflate, br" | ||
"accept-language" = "en-US,en;q=0.9" | ||
"cookie" = "timezone=420; over18=18; __cfduid=$SessionCFDUID; userid=$($Settings.JavLibrary.username); session=$($Settings.JavLibrary.'session-cookie')" | ||
} ` | ||
-ContentType "application/x-www-form-urlencoded; charset=UTF-8" ` | ||
-Body "type=2&targetid=$AjaxId" ` | ||
-Verbose:$false | ||
} | ||
$check = Invoke-WebRequest -Uri "https://www.javlibrary.com/ajax/ajax_cv_favoriteadd.php" ` | ||
-Method "POST" ` | ||
-Headers @{ | ||
"method" = "POST" | ||
"authority" = "www.javlibrary.com" | ||
"scheme" = "https" | ||
"path" = "/ajax/ajax_cv_favoriteadd.php" | ||
"accept" = "application/json, text/javascript, */*; q=0.01" | ||
"x-requested-with" = "XMLHttpRequest" | ||
"user-agent" = $session.UserAgent | ||
"origin" = "https://www.javlibrary.com" | ||
"sec-fetch-site" = "same-origin" | ||
"sec-fetch-mode" = "cors" | ||
"sec-fetch-dest" = "empty" | ||
"referer" = $JavlibraryUrl | ||
"accept-encoding" = "gzip, deflate, br" | ||
"accept-language" = "en-US,en;q=0.9" | ||
"cookie" = "timezone=420; over18=18; __cfduid=$SessionCFDUID; userid=$($Settings.JavLibrary.username); session=$($Settings.JavLibrary.'session-cookie')" | ||
} ` | ||
-ContentType "application/x-www-form-urlencoded; charset=UTF-8" ` | ||
-Body "type=2&targetid=$AjaxId" ` | ||
-Verbose:$false | ||
} | ||
|
||
if ($stopwatch.elapsed -gt $timeout) { | ||
Write-Error "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Movie [$JavlibraryUrl] timed out while setting owned status" | ||
Write-Log -Log $javinizerLogPath -Level ERROR -Text "Movie [$JavlibraryUrl] timed out while setting owned status" | ||
if ($stopwatch.elapsed -gt $timeout) { | ||
Write-JVLog -Level Warning -Message "Failed setting owned on JAVLibrary [$JavlibraryUrl]: Timed out" | ||
} | ||
} catch { | ||
Write-JVLog -Level Error -Message "Failed setting owned on JAVLibrary [$JavlibraryUrl]: $PSItem" | ||
} | ||
} catch { | ||
Write-Error "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Error setting owned status for [$JavlibraryUrl]: $PSItem" | ||
Write-Log -Log $javinizerLogPath -Level ERROR -Text "Error setting owned status for [$JavlibraryUrl]: $PSItem" | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,68 @@ | ||
function Write-JVLog { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string]$Message, | ||
[Parameter(Mandatory = $true, Position = 0)] | ||
[String]$Message, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[Parameter(Mandatory = $true, Position = 1)] | ||
[ValidateSet('Debug', 'Info', 'Warning', 'Error')] | ||
[string]$Level, | ||
[String]$Level, | ||
|
||
[Parameter()] | ||
[AllowEmptyString()] | ||
[String]$Write, | ||
|
||
[Parameter()] | ||
[AllowEmptyString()] | ||
[String]$WriteLevel, | ||
|
||
[Parameter()] | ||
[AllowEmptyString()] | ||
[String]$LogPath, | ||
|
||
[Parameter()] | ||
[ValidateSet('Break', 'Continue', 'Ignore', 'Inquire', 'SilentlyContinue', 'Stop', 'Suspend')] | ||
[string]$Action = 'Stop' | ||
[String]$Action = 'Stop' | ||
) | ||
|
||
$timeStamp = Get-Date -Format s | ||
|
||
if ($Level -eq 'Debug') { | ||
Write-Debug -Message $Message | ||
Write-Log -Level $Level -Message $Message | Wait-Logging | ||
if ($WriteLevel -eq 'Debug') { | ||
$formattedMessage = "[$timeStamp][DEBUG] $Message" | ||
} | ||
Write-Debug -Message "$Message" | ||
} | ||
|
||
if ($Level -eq 'Info') { | ||
if ($WriteLevel -eq 'Debug' -or $WriteLevel -eq 'Info') { | ||
$formattedMessage = "[$timeStamp][INFO ] $Message" | ||
} | ||
Write-Verbose -Message $Message | ||
Write-Log -Level $Level -Message $Message | Wait-Logging | ||
} | ||
|
||
if ($Level -eq 'Warning') { | ||
if ($WriteLevel -eq 'Debug' -or $WriteLevel -eq 'Info' -or $WriteLevel -eq 'Warning') { | ||
$formattedMessage = "[$timeStamp][WARN ] $Message" | ||
} | ||
Write-Warning -Message $Message | ||
Write-Log -Level $Level -Message $Message | Wait-Logging | ||
} | ||
|
||
if ($Level -eq 'Error') { | ||
Write-Log -Level $Level -Message $Message | Wait-Logging | ||
if ($writeLevel -eq 'Debug' -or $WriteLevel -eq 'Info' -or $WriteLevel -eq 'Warning' -or $WriteLevel -eq 'Error') { | ||
$formattedMessage = "[$timeStamp][ERROR] $Message" | ||
} | ||
Write-Error -Message $Message -ErrorAction $Action | ||
} | ||
|
||
if ($LogPath -ne '' -and $null -ne $LogPath) { | ||
if ($formattedMessage -ne '' -and $null -ne $formattedMessage) { | ||
if ($Write -eq 1) { | ||
$LogMutex = New-Object System.Threading.Mutex($false, "LogMutex") | ||
$LogMutex.WaitOne() | Out-Null | ||
$formattedMessage | Out-File -FilePath $LogPath -Append | ||
$LogMutex.ReleaseMutex() | Out-Null | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.