Created
January 25, 2017 04:41
-
-
Save zizhengwu/5498eb1a0167afc6900c1fcb566d1b46 to your computer and use it in GitHub Desktop.
powershell IEX (New-Object Net.WebClient).DownloadString('https://gist.githubusercontent.com/zizhengwu/5498eb1a0167afc6900c1fcb566d1b46/raw/ffb3209146aa2533d57c9fb2383c3a2560316b1c/douyu-notify-danche')
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
$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