Created
March 1, 2020 19:55
-
-
Save steinuil/62f3f24d6a1d2c9c033252ada55d6e54 to your computer and use it in GitHub Desktop.
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
# You have two options to run this script: | |
# - Run with powershell (smol brain): | |
# You save the script somewhere and then you right click on it and select "Run with PowerShell". | |
# You'll have to right click every time you want to run it, and you'll get an ugly blue powershell window every time. | |
# If you choose this method, you must have small brain. | |
# You might as well just watch the damn vtuber stream on youtube as befitting of somebody of your intellectual stature. | |
# - Convert to exe (big brain): | |
# You download this shit: | |
# https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI-Convert-e7cb69d5 | |
# Then you're on your own. You should be able to solve this. | |
$STREAMLINK = "C:\Program Files (x86)\Streamlink\bin\streamlink.exe" | |
Add-Type -AssemblyName System.Windows.Forms | |
Add-Type -AssemblyName System.Drawing | |
$form = New-Object System.Windows.Forms.Form -Property @{ | |
Text = "Vtuber Stream Opener" | |
StartPosition = 'CenterScreen' | |
Size = [System.Drawing.Size]::new(300, 53) | |
AutoSize = $true | |
FormBorderStyle = 'FixedSingle' | |
} | |
$urlLabel = New-Object System.Windows.Forms.Label -Property @{ | |
Text = "url" | |
Location = [System.Drawing.Point]::new(2, 10) | |
} | |
$textBox = New-Object System.Windows.Forms.TextBox -Property @{ | |
Location = [System.Drawing.Point]::new(24, 7) | |
Size = [System.Drawing.Size]::new(200, 10) | |
} | |
$okButton = New-Object System.Windows.Forms.Button -Property @{ | |
Text = "go" | |
Location = [System.Drawing.Point]::new(224, 6) | |
Size = [System.Drawing.Size]::new(35, 22) | |
} | |
$cancelButton = New-Object System.Windows.Forms.Button -Property @{ | |
Text = "fug" | |
Location = [System.Drawing.Point]::new(258, 6) | |
Size = [System.Drawing.Size]::new(35, 22) | |
} | |
Function OpenStream($stream) { | |
} | |
$okButton.Add_Click({ | |
if ($textBox.Text.Length -lt 1) { | |
return | |
} | |
$textBox.Enabled = $false | |
$okButton.Enabled = $false | |
$resp = & $STREAMLINK --json $textBox.Text | ConvertFrom-Json | |
if ($resp.error) { | |
[System.Windows.Forms.MessageBox]::Show( | |
$resp.error, | |
"Oopsie Woopsie!!!", | |
[System.Windows.Forms.MessageBoxButtons]::OK, | |
[System.Windows.Forms.MessageBoxIcon]::Error | |
) | |
$form.Close() | |
return | |
} | |
$streams = $resp.streams.PSObject.Members | | |
Where-Object { $_.MemberType -eq 'NoteProperty' } | | |
Select -ExpandProperty Name | |
$i = 0 | |
$streams | foreach { | |
$stream = $_ | |
$button = New-Object System.Windows.Forms.Button -Property @{ | |
Text = $stream | |
Location = [System.Drawing.Point]::new(24, 34 + 22 * $i) | |
} | |
$button.Add_Click({ | |
Start-Process -NoNewWindow $STREAMLINK -ArgumentList $textBox.Text, $stream | |
$form.Close() | |
}.GetNewClosure()) | |
$form.Controls.Add($button) | |
$i = $i + 1 | |
} | |
}) | |
$form.Controls.AddRange(($textBox,$urlLabel,$okButton,$cancelButton)) | |
$form.CancelButton = $cancelButton | |
$form.AcceptButton = $okButton | |
$form.ShowDialog() | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment