View Single Post
  #378  
Old 13.03.2018, 16:27
patriks's Avatar
patriks patriks is offline
Super Loader
 
Join Date: Aug 2017
Location: Brasil
Posts: 29
Default

mgpai/Jiaz thank you very much, the script was perfect

for anyone who wants to use:
Code:
// Simple history
// Trigger Required : A Download Stopped
disablePermissionChecks();

// Function
function now() {
    var d = new Date();
    var t = d.toString().split(" ");
    return t[3] + ('0' + (d.getMonth() + 1)).slice(-2) + t[2] + " " + t[4];
}

if (link.isFinished()) {
    var a /*date*/ = now();
    var b /*history folder*/ = JD_HOME + "/auto/";
    var c /*file Name */ = "_history.txt";
    var d /*download url*/ = link.getContentURL();
    var e /*download file name*/ = link.getName();
    var ig /*instagram directurl*/ = link.getProperty("directurl");
    var g /*other directurl*/ = link.getProperty("url");
    var vk /*vkontakte directurl*/ = link.getProperty("picturedirectlink");

    if (!getPath(b).exists()) getPath(b).mkdirs();
    writeFile(b + c, [a, vk, ig, g, d, e].join(",") + "\r\n", true);
}
original:
Quote:
Originally Posted by mgpai View Post
Simple history of downloaded links in text format.
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\history")
  • Default file name: "<current date>.txt" (e.g. "Oct 07 2016.txt")
Code:
// Simple history
// Trigger Required : A Download Stopped

if (link.isFinished()) {
    var a /*date*/ = new Date().toString().substring(4, 16);
    var b /*history folder*/ = JD_HOME + "/auto/history/";
    var c /*history file Name */ = a + ".txt";
    var d /*download url*/ = link.getContentURL();
    var e /*download file name*/ = link.getName();

    if (!getPath(b).exists()) getPath(b).mkdirs();
    writeFile(b + c, [d, e].join(",") + "\r\n", true);
}
~~~~~~
Quote:
Originally Posted by mgpai View Post
Code:
github.com/mgpai/resources/blob/master/jdownloader/eventscripter/scripts/patriks.js



Code:
github.com/mgpai/resources/blob/master/jdownloader/eventscripter/scripts/patriks_2.js



If you are using callAsync() methods in the script, try using callSync() instead.

mgpai is it possible to make the script ignore and delete the duplicate links?
the script does not understand a adv settings for dupes "do NOT add, but remove them from linkgrabber"

About sync:


I was able to reproduce this using two simple scripts:

synchronous execution of script: ok
interval: 40000
Code:
disablePermissionChecks();
callAPI("linkgrabberv2", "addLinks", {
    "autostart": true,
    "autoConfirm": true,
    "deepDecrypt": false,
    "links": "**External links are only visible to Support Staff**
})
synchronous execution of script: ok
interval: 30000
Code:
disablePermissionChecks();
callAPI("linkgrabberv2", "addLinks", {
    "autostart": true,
    "autoConfirm": true,
    "deepDecrypt": false,
    "links": "**External links are only visible to Support Staff**
})
~~~~~~
cfg/org.jdownloader.extensions.eventscripter.EventScripterExtension.scripts.json
Code:
[ {
  "eventTrigger" : "INTERVAL",
  "enabled" : true,
  "name" : "tst240s",
  "script" : "disablePermissionChecks();\ncallAPI(\"linkgrabberv2\", \"addLinks\", {\n    \"autostart\": true,\n    \"autoConfirm\": true,\n    \"deepDecrypt\": false,\n    \"links\": \"**External links are only visible to Support Staff**\n})",
  "eventTriggerSettings" : {
    "lastFire" : 1520950333534,
    "interval" : 40000,
    "isSynchronous" : true
  },
  "id" : 1520949865121
}, {
  "eventTrigger" : "INTERVAL",
  "enabled" : true,
  "name" : "tst130s",
  "script" : "disablePermissionChecks();\ncallAPI(\"linkgrabberv2\", \"addLinks\", {\n    \"autostart\": true,\n    \"autoConfirm\": true,\n    \"deepDecrypt\": false,\n    \"links\": \"**External links are only visible to Support Staff**\n})",
  "eventTriggerSettings" : {
    "lastFire" : 1520950364036,
    "interval" : 30000,
    "isSynchronous" : true
  },
  "id" : 1520949856117
} ]
Reply With Quote