Skip to content

Instantly share code, notes, and snippets.

@zizhengwu
Created January 25, 2017 04:41
Show Gist options
  • Save zizhengwu/5498eb1a0167afc6900c1fcb566d1b46 to your computer and use it in GitHub Desktop.
Save zizhengwu/5498eb1a0167afc6900c1fcb566d1b46 to your computer and use it in GitHub Desktop.
$room="danche"
$request_interval=100
Add-Type -AssemblyName System.Windows.Forms
function is_stream() {
$url="http://www.douyutv.com/"+$room
$reply=(New-Object System.Net.WebClient).DownloadString($url)
$status = $reply.Contains("feedback-report-button")
return $status
}
Write-Output("start monitoring streaming status of " + $room)
while($true){
Try {
if (is_stream) {
Write-Output($room + ' started live streaming at '+ (Get-Date -format MMdd_HHmm))
$oReturn=[System.Windows.Forms.MessageBox]::Show("press OK to launch "+$room,$room,[System.Windows.Forms.MessageBoxButtons]::OKCancel)
switch ($oReturn){
"OK" {
write-host "pressed OK"
$url="http://www.douyutv.com/"+$room
start $url
}
"Cancel" {
write-host "pressed Cancel"
# Enter some code
}
}
while (is_stream) {Start-Sleep -Seconds 1800}
}
Start-Sleep -Seconds $request_interval
}
catch {
Write-Warning "Error occured: $_"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment