Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $waifu = Read-Host -Prompt "Waifu name?"
- $auto_complete_url = "https://gelbooru.com/index.php?page=autocomplete&term=$waifu"
- $response = Invoke-WebRequest $auto_complete_url
- $completions = $response.Content -split ',' -replace '[\[\]"]',''
- if($completions.Length -gt 1)
- {
- Write-Host "Found multiple choices for your waifu."
- for($i = 1; $i -le $completions.Length; $i++)
- {
- Write-Host "${i}:" $completions[$i - 1]
- }
- $hasChosenNumber = $false
- while(-not $hasChosenNumber)
- {
- $number = Read-Host -Promt "Please select the number you intended."
- $number = $number - '0'
- if($number -match "\d" -and $number -le $completions.Length -and $number -ge 1)
- {
- $waifu = $completions[$number - 1]
- $hasChosenNumber = $true
- }
- else
- {
- Write-Host "Please enter a valid number (e.g. 1)"
- }
- }
- Write-Host ""
- Write-Host ""
- Write-Host "You have chosen $waifu."
- Write-Host "Images will now be downloaded. After the download please write the same name on the solitair start-up."
- Write-Host ""
- Write-Host "E.g. if Morgana from League of Legends is your waifu, you should write 'morgana_(league_of_legends)' and not only 'morgana'."
- Write-Host ""
- }
- else
- {
- Write-Host ""
- Write-Host "You have chosen $waifu as a waifu."
- Write-Host "Images will now be downloaded. After the download please write the same name on the solitair start-up."
- Write-Host ""
- }
- $waifu_path = "waifus\$waifu"
- if (-not (Test-Path $waifu_path))
- {
- mkdir "waifus\$waifu" | Out-Null
- $full_page = $true
- $match_count = 0
- $page = 0
- while($full_page -and $page -lt 3)
- {
- $start_page_id = 42 * $page
- $main_url_base = "https://gelbooru.com/index.php?page=post&s=list&tags=$waifu+rating%3aexplicit+sort%3ascore%3adesc+-animated_gif+-animated+-webm+solo+-absurdres&pid=$start_page_id"
- $response = Invoke-WebRequest $main_url_base
- ($response.Content | Select-String -Pattern 'js-pop" id="p.\d*" href="(.*?)"' -AllMatches).Matches.Value |
- % {
- $_ -match 'js-pop" id="p.\d*" href="(.*?)"' | Out-Null
- $match_count = ($match_count + 1);
- $url = "https:" + ($Matches[1] -replace "amp;","")
- $response = Invoke-WebRequest $url
- $response.Content -match 'href="(https://img2.gelbooru.com/images/.*?\.(.*?))"' | Out-Null
- $out_path = "$waifu_path\$match_count." + $Matches[2]
- $img = Invoke-WebRequest $Matches[1] -OutFile $out_path
- }
- $page++
- $full_page = $match_count -eq 42
- }
- }
- .\waifu_solitaire.exe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement