View Single Post
  #1373  
Old 18.05.2020, 08:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by sherif011 View Post
I mean, I just need to set the limit for the current session, just after I click start, without counting previous downloads.
NOTE: Do not delete partiallly/completely downloaded links from the list, when the downloads are running.

Code:
// Limit per download session
// Trigger: Download Controller Started

var limit = 20; // <- Session limit (GB)
var interval = 30; // <- Interval between checks (seconds)

var getLoadedBytes = function() {
    return callAPI("polling", "poll", {
        "aggregatedNumbers": true
    })[0].eventData.data.loadedBytes;
}

var loadedBytes = getLoadedBytes();

while (isDownloadControllerRunning() || isDownloadControllerPaused()) {
    sleep(interval * 1000);
    if ((getLoadedBytes() - loadedBytes) / 1e9 > limit) stopDownloads();
}
Reply With Quote