Quote:
Originally Posted by bobolecoco
So if 2 downloads start, the script will run twice ?
|
Yes
Quote:
Originally Posted by bobolecoco
Should I use "Download controller started" trigger instead if I want only one instance to run ?
|
Yes
Quote:
Originally Posted by bobolecoco
A problem I have is when twitch's server is not reachable for a brief moment : it triggers an error, and the script disables itself.
|
Use try/catch.
Sample Code (Totally untested)
:
Code:
// Toggle Speed Limit
// Trigger: Download Controller Started
// IMPORTANT: Disable 'Synchronous Execution'
while (isDownloadControllerRunning()) {
if (streaming()) {
setSpeedlimit(1.5 * 1024 * 1024);
} else {
setSpeedlimit(0);
}
sleep(30000);
}
//Functions
function streaming() {
try {
var myBrowser = getBrowser();
myBrowser.setHeader("Accept", "application/vnd.twitchtv.v3+json");
myBrowser.setHeader("Client-ID", "HereIsMyPrivateClientId");
myBrowser.getPage("hxxps://api.twitch.tv/kraken/streams/TheNameOfTheTwitchChannel");
return /"stream":null/.test(myBrowser.getHTML());
} catch (e) {
//On error assume it is atreaming?
return true;
}
}