Skip to content

Instantly share code, notes, and snippets.

@potat-dev
Last active May 11, 2025 00:15
Show Gist options
  • Save potat-dev/d87671801f30aa71f8c3c95783d27e09 to your computer and use it in GitHub Desktop.
Save potat-dev/d87671801f30aa71f8c3c95783d27e09 to your computer and use it in GitHub Desktop.
PowerShell script to download and run the latest zapret-discord-youtube release
# Config
$repo = 'Flowseal/zapret-discord-youtube'
$installDir = Join-Path $env:LOCALAPPDATA 'zapret'
# Fetch the latest GitHub release info
Write-Host "Checking latest release..."
$apiUrl = "https://api.github.com/repos/$repo/releases/latest"
$release = Invoke-RestMethod -Uri $apiUrl -UseBasicParsing
# Look for a .rar asset in the release
$rar = $release.assets | Where-Object { $_.name -like '*.rar' } | Select-Object -First 1
if (-not $rar) {
Write-Host "No .rar file found in latest release."
exit 1
}
Write-Host "Release found: $($rar.name)"
$tempRar = Join-Path $env:TEMP $rar.name
# Ensure the install directory exists
if (-not (Test-Path $installDir)) {
Write-Host "Creating install directory..."
New-Item -ItemType Directory -Path $installDir | Out-Null
}
# Try to clean old files from the install directory
Write-Host "Cleaning old files..."
try {
Get-ChildItem -Path $installDir -Force | Remove-Item -Recurse -Force -ErrorAction Stop
} catch {
Write-Host "Some files could not be removed. Continuing..."
}
# Download the .rar archive to a temp location
Write-Host "Downloading $($rar.name)..."
Invoke-WebRequest -Uri $rar.browser_download_url -OutFile $tempRar
# Extract the archive contents to the install directory
Write-Host "Extracting to $installDir..."
& tar.exe -xkf $tempRar -C $installDir
# Launch the main script from the archive
$bat = Join-Path $installDir 'discord.bat'
if (Test-Path $bat) {
Write-Host "Launching discord.bat..."
Start-Process -FilePath $bat -WorkingDirectory $installDir
} else {
Write-Host "discord.bat not found."
exit 1
}
# Delete the temporary archive file
Write-Host "Cleaning up..."
Remove-Item $tempRar -Force
# Final message
Write-Host "Done. Have a nice day!"
# Easter Egg 1: Open a silly woodcock video in the default browser
Start-Process "https://www.youtube.com/watch?v=YF3-LvmHM4E"
# Easter Egg 2: Print a weather report to the terminal
try {
$req = [System.Net.WebRequest]::Create("https://wttr.in/?0F")
$req.Timeout = 3500
$req.UserAgent = "curl"
$resp = $req.GetResponse()
$reader = New-Object System.IO.StreamReader($resp.GetResponseStream())
$null = $reader.ReadToEnd()
$resp.Close()
} catch {
# silently ignore
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment