View Single Post
  #4  
Old 06.09.2016, 15:22
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Update JD when idle.
Code:
// Restart and Update JD when idle
// Trigger Required: "Interval"

var newInterval = 600000;

if (interval == newInterval) {
    if (isDownloadControllerIdle()) {
        if (isUpdateAvailable() && !isExtracting() && !isCrawling()) {
            restartAndUpdate();
        } else {
            if (!isAutoUpdateCheckEnabled()) {
                runUpdateCheck();
            }
        }
    }
} else {
    interval = newInterval;
}

//Functions

function isUpdateAvailable() {
    return callAPI("update", "isUpdateAvailable");
}

function isExtracting() {
    return callAPI("extraction", "getQueue").length > 0;
}

function isCrawling() {
    return callAPI("linkcrawler", "isCrawling");
}

function restartAndUpdate() {
    callAPI("update", "restartAndUpdate");
}

function isAutoUpdateCheckEnabled() {
    return callAPI("config", "get", "org.jdownloader.updatev2.UpdateSettings", null, "autoupdatecheckenabled");
}

function runUpdateCheck() {
    callAPI("update", "runUpdateCheck");
}

Updated version of the script can be found in Post# 881 of this thread.

Last edited by mgpai; 15.09.2019 at 10:52. Reason: Link to new version of the script.
Reply With Quote