There was a problem loading the comments.

Script: Automatically update JD when it is in idle

Support Portal  »  Knowledgebase  »  Viewing Article


By default, JDownloader will update itself whenever it is closed/restarted.

However, especially for Headless/Server JD installations, this might not be ideal ideal because JD might always be running but the user would need to manually trigger the installation of updates whenever they're available.
The following script has two main features:

  1. Auto update JD whenever it is in idle
  2. Auto update JD all X hours regardless whether it is in idle or not.

 

// Restart & Update when JD is idle, or after 'x' hours.
// Trigger: Interval (Recommended 600000 or more).

var hours = 0; // Update after 'x' hours, even if JD is not idle. (0 = Disabled)

if (callAPI("update", "isUpdateAvailable")) {

    var updateNow = false;

    if (hours > 0) {
        
        if (!getProperty("date", false)) {
            setProperty("date", new Date(Date.now() + hours * 60 * 60 * 1000), false);
        }

        if (Date.now() > getProperty("date", false)) {
            updateNow = true;
        }
    }

    if (!updateNow) {
        
        var idle = isDownloadControllerIdle() &&
            !callAPI("linkcrawler", "isCrawling") &&
            !callAPI("linkgrabberv2", "isCollecting") &&
            !callAPI("extraction", "getQueue").length > 0;

        if (idle) {
            updateNow = true;
        }
    }

    if (updateNow) {
        callAPI("update", "restartAndUpdate");
    }
}

Script without line-breaks to easily add it to your (headless) JD via advanced settings:

[ {
  "eventTrigger" : "INTERVAL",
  "enabled" : true,
  "name" : "Auto-update JD",
  "script" : "// Restart & Update when JD is idle, or after 'x' hours.\n// Trigger: Interval (Recommended 600000 or more).\n\nvar hours = 0; // Update after 'x' hours, even if JD is not idle. (0 = Disabled)\n\nif (callAPI(\"update\", \"isUpdateAvailable\")) {\n\n    var updateNow = false;\n\n    if (hours > 0) {\n        \n        if (!getProperty(\"date\", false)) {\n            setProperty(\"date\", new Date(Date.now() + hours * 60 * 60 * 1000), false);\n        }\n\n        if (Date.now() > getProperty(\"date\", false)) {\n            updateNow = true;\n        }\n    }\n\n    if (!updateNow) {\n        \n        var idle = isDownloadControllerIdle() &&\n            !callAPI(\"linkcrawler\", \"isCrawling\") &&\n            !callAPI(\"linkgrabberv2\", \"isCollecting\") &&\n            !callAPI(\"extraction\", \"getQueue\").length > 0;\n\n        if (idle) {\n            updateNow = true;\n        }\n    }\n\n    if (updateNow) {\n        callAPI(\"update\", \"restartAndUpdate\");\n    }\n}",
  "eventTriggerSettings" : {
    "lastFire" : 1594799412187,
    "interval" : 600000,
    "isSynchronous" : false
  },
  "id" : 1594796988140
} ]

Source


Related Articles


On-Premise Help Desk Software by SupportPal