View Single Post
  #1204  
Old 11.03.2020, 18:15
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Bunter fisch View Post
my JDownloader is running headless on my raspberry pi. i want to automaticcally restart jdownloader when new updates are available and no download is runnung.
You don't need to add any button. The script uses 'interval' as trigger.

You can install the eventscripter in JD GUI and setup/test the script in in it and copy the 'EventScripter.scripts' JSON data from its 'value' column and paste it in the headless JD using WebUI.

Alternatively, after installing the script in JD GUI, you can copy the "org.jdownloader.extensions.eventscripter.EventScripterExtension.scripts.json" file from JD GUI to the headless version.

This is the script in JSON format, which can be added (using WebuI) in 'EventScripter.scripts' advanced setting of headless JD.

Code:
[ {
  "eventTrigger" : "INTERVAL",
  "enabled" : true,
  "name" : "Update JD when idle",
  "script" : "// Update when JD is Idle\n// Trigger Required: \"Interval\"\n// Set interval to 600000 (10 mins.) or more.\n\ndisablePermissionChecks();\n\n(function() {\n    if (callAPI(\"update\", \"isUpdateAvailable\") == false) return;\n    if (callAPI(\"linkcrawler\", \"isCrawling\")) return;\n    if (callAPI(\"linkgrabberv2\", \"isCollecting\")) return;\n    if (callAPI(\"extraction\", \"getQueue\").length > 0) return;\n    if (callAPI(\"downloadcontroller\", \"getCurrentState\") != \"IDLE\") return;\n    callAPI(\"update\", \"restartAndUpdate\");\n})();",
  "eventTriggerSettings" : {
    "lastFire" : 1583942603250,
    "interval" : 600000,
    "isSynchronous" : false
  },
  "id" : 1583942586078
} ]

Please note, Eventscripter extension must be installed/enabled for it to work.
Reply With Quote