View Single Post
  #735  
Old 30.05.2019, 22:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by bobolecoco View Post
So if 2 downloads start, the script will run twice ?
Yes

Quote:
Originally Posted by bobolecoco View Post
Should I use "Download controller started" trigger instead if I want only one instance to run ?
Yes

Quote:
Originally Posted by bobolecoco View Post
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;
    }
}
Reply With Quote