Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- List-Ignored.ps1 -file <file.json> [-delay <seconds>]
- Where: file.json = CTBRec config file, (usually ctbrec.json or server.json)
- seconds = Delay between each Web Request, (avoid possible error 503), valid range 0.1-90
- example: List-Ignored.ps1 -file server.json
- List-Ignored.ps1 -file ctbrec.json -delay 3
- List ignored models with pages that don't resolve, (error 404, etc), or CB models that are banned.
- Output will be to Ignored-Model-Status.txt in the same dir as List-Ignored.ps1.
- File will be overwritten in consecutive runs.
- Tested on PowerShell 7, Windows 10 and DietPi 6.33.3, (RasPi).
- *** NOTE: Only tested with a few models on CB because I only monitor 1-3 models there, so if
- no-one tells me anything I'll assume it works on all sites.
- #>
- param (
- [Parameter(Mandatory=$true)][string]$file,
- [ValidateRange(0.1,90)][decimal]$delay
- )
- function Test-Url ([string] $Url) {
- $req = [system.Net.HttpWebRequest]::Create($url)
- try {
- $res = $req.GetResponse()
- }
- catch [System.Net.WebException] {
- $res = $_.Exception.Response
- }
- $res.Close()
- return $res
- }
- function Test-Models ([string] $infile) {
- $json = (Get-Content $infile | ConvertFrom-Json)
- for ($i = 0; $i -lt $json.modelsIgnored.Count; $i++) {
- $statusCode = [int](Test-Url $json.modelsIgnored[$i].url).StatusCode
- "$($i) - $($json.modelsIgnored[$i].name) - $($statusCode)"
- if ($statusCode -gt 399) {
- "$($json.modelsIgnored[$i].name) - Error $($statusCode)" | Out-File -FilePath Ignored-Model-Status.txt -Append
- } else {
- if ($json.modelsIgnored[$i].type -match 'chaturbate') {
- $data = Invoke-WebRequest -Uri $json.modelsIgnored[$i].url
- if ($data -match 'This room has been banned') {
- "$($json.modelsIgnored[$i].name) - Banned" | Out-File -FilePath Ignored-Model-Status.txt -Append
- }
- }
- }
- if ($delay -gt 0) {
- Start-Sleep -Seconds $delay
- }
- }
- }
- if (Test-Path ./Ignored-Model-Status.txt) {
- Remove-Item ./Ignored-Model-Status.txt -Force
- }
- Test-Models $file
Add Comment
Please, Sign In to add comment