Guest User

Waifu Solitair Fix 4.1 with link to Tutorial

a guest
Jul 25th, 2021
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # If you want to change the website, pls look into the file start_rule34xxx.ps1 (https://pastebin.com/H4LAjX7b)
  2. # There are some pointers on how to start and do this.
  3.  
  4. $waifu = Read-Host -Prompt "Waifu name?"
  5.  
  6. $auto_complete_url = "https://gelbooru.com/index.php?page=autocomplete2&term=$waifu"
  7.  
  8. $response = Invoke-WebRequest $auto_complete_url
  9. $array_of_completions = $response.Content | ConvertFrom-Json
  10.  
  11. if($array_of_completions.Length -gt 1)
  12. {
  13.     Write-Host "Found multiple choices for your waifu."
  14.    
  15.     $completions = $response.Content | ConvertFrom-Json | ForEach-Object { $_.Value }
  16.    
  17.     for($i = 1; $i -le $completions.Length; $i++)
  18.     {
  19.         Write-Host "${i}:" $completions[$i - 1]
  20.     }
  21.  
  22.     $hasChosenNumber = $false
  23.  
  24.     while(-not $hasChosenNumber)
  25.     {
  26.         $number = Read-Host "Please select the number you intended."
  27.  
  28.         $number = $number - '0'
  29.  
  30.         if($number -match "\d" -and $number -le $completions.Length -and $number -ge 1)
  31.         {
  32.             $waifu = $completions[$number - 1]
  33.             $hasChosenNumber = $true
  34.         }
  35.         else
  36.         {
  37.             Write-Host "Please enter a valid number (e.g. 1)"
  38.         }
  39.     }
  40.  
  41.     Write-Host ""
  42.     Write-Host "You have chosen '$waifu' as a waifu."
  43.     Write-Host "Images will now be downloaded. After the download please write the same name on the solitair start-up."
  44.     Write-Host ""
  45.     Write-Host "E.g. if Morgana from League of Legends is your waifu, you should write 'morgana_(league_of_legends)' and not only 'morgana'."
  46.     Write-Host "You can select the name between the 's and press enter to copy the text. Then just paste it by pressing right click into the console window."
  47.     Write-Host ""
  48. }
  49. else
  50. {
  51.     Write-Host ""
  52.     Write-Host "You have chosen '$waifu' as a waifu."
  53.     Write-Host "Images will now be downloaded. After the download please write the same name on the solitair start-up."
  54.     Write-Host "You can select the name between the 's and press enter to copy the text. Then just paste it by pressing right click into the console window."
  55.     Write-Host ""
  56. }
  57.  
  58. $waifu_path = "waifus\$waifu"
  59.  
  60. if (-not (Test-Path $waifu_path))
  61. {
  62.     mkdir "waifus\$waifu" | Out-Null
  63.  
  64.     $full_page = $true
  65.     $match_count = 0
  66.     $page = 0
  67.  
  68.     while($full_page -and $page -lt 3)
  69.     {
  70.         $start_page_id = 42 * $page
  71.  
  72.         $main_url_base = "https://gelbooru.com/index.php?page=post&s=list&tags=$waifu+rating%3aexplicit+sort%3ascore%3adesc+-animated_gif+-animated+-webm+-solo&pid=$start_page_id"
  73.  
  74.         $response = Invoke-WebRequest $main_url_base -UseBasicParsing
  75.  
  76.         $url_pattern = '<a id="p.\d*" href="(.*?)"'
  77.  
  78.         ($response.Content | Select-String -Pattern $url_pattern -AllMatches).Matches.Value |
  79.         ForEach-Object {
  80.             $_ -match $url_pattern | Out-Null
  81.  
  82.             $match_count = ($match_count + 1);
  83.             $url = ($Matches[1] -replace "amp;","")
  84.             $response = Invoke-WebRequest $url
  85.  
  86.             $response.Content -match 'href="(https://img\d.gelbooru.com/images/.*?\.(.*?))"' | Out-Null
  87.  
  88.             $out_path = "$waifu_path\$match_count." + $Matches[2]
  89.        
  90.             Invoke-WebRequest $Matches[1] -OutFile $out_path | Out-Null
  91.  
  92.             if ($match_count % 10 -eq 0)
  93.             {
  94.                 Write-Host "Downloaded $match_count images so far."
  95.             }
  96.         }
  97.         $page++
  98.  
  99.         $full_page = $match_count -eq 42
  100.     }
  101. }
  102.  
  103. .\waifu_solitaire.exe
Add Comment
Please, Sign In to add comment