View Single Post
  #734  
Old 30.05.2019, 21:16
bobolecoco bobolecoco is offline
Super Loader
 
Join Date: Aug 2015
Location: France
Posts: 27
Default Thanks

Thanks, it worked. So if 2 downloads start, the script will run twice ? Should I use "Download controller started" trigger instead if I want only one instance to run ?

I already have a working script, it runs every 30 seconds (interval 30000). But it's relevant only when a download is running. It allows me to put a speed limit when a twitch channel is streaming, so bandwidth stay available to watch the stream. Here it is :
Code:
var myBrowser = getBrowser();
myBrowser.setHeader("Accept", "application/vnd.twitchtv.v3+json");
myBrowser.setHeader("Client-ID", "HereIsMyPrivateClientId");
myBrowser.getPage("**External links are only visible to Support Staff**);

if (!/"stream":null/.test(myBrowser.getHTML())) {
    setSpeedlimit(1.5 * 1024 * 1024);
} else {
    setSpeedlimit(0);
}
It's not relevant to run it when no file is being downloaded, but it need to be run periodically (every 30sec) when it is the case. That's why I was looking for triggers like "A download started" or "Download controller started" and use a while loop or a function that calls itself while "isDownloadControllerRunning()" is true.

Am I clear enough (English is not my natural language) ?

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. So running it only when downloading reduce the probability to trigger that error. An other solution would be to extent time before a timeout error is fired, but I didn't find any option like this with getBrowser().

A reliable way to do it would be to create an external script that check if there is a streaming, that JD runs from event scripter. But my idea was to NOT use an external script.
Reply With Quote