JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #181  
Old 31.03.2021, 15:44
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 615
Default

Thank goodness mgpai brought everything back to work in the chat.

And thank you also for your help!
__________________
Aktuelles Windows

Last edited by Dockel; 31.03.2021 at 15:47.
Reply With Quote
  #182  
Old 02.04.2021, 01:54
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

could you plz update any new solution or script here?
Reply With Quote
  #183  
Old 22.04.2021, 18:46
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 615
Default

After clicking "Move to history" this is shown:


Those error messages sometimes occur. Is there anything one could do to avoid them?
__________________
Aktuelles Windows
Reply With Quote
  #184  
Old 23.04.2021, 10:11
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

@Dockel:
can you export all scripts and send them to support@jdownloader.org then I can check them and fix this issue. most likely there is access to non existing field/item
__________________
JD-Dev & Server-Admin
Reply With Quote
  #185  
Old 23.04.2021, 13:52
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 615
Default

Yes, of course, thank you very much! Just done.
__________________
Aktuelles Windows
Reply With Quote
  #186  
Old 23.04.2021, 16:08
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

Play a Sound(Wav), Interval, the script doesn't check if the link is still in list/available
Quote:
var extracting = false;
/*
================ Check if there are running extraction processes=====================
This Script es executed in an interval of 1 second (1000 ms) and will check
the current active state. If the state changes to false, it will play a wav file
=====================================================================================
*/


//use an API Call to get all Downloadlinks in your list
var links = callAPI("downloadsV2", "queryLinks", {
"name": true
});
//loop through all links
for (var i = 0; i < links.length; i++) {
//convert API Link to a Link Object
var link = getDownloadLinkByUUID(links[i].uuid);
if (link){
//check if the link is currently in extraction state
var isExtracting = link.getExtractionStatus() == "RUNNING";

if (isExtracting) {
//if it is, set variable and break the loop
extracting = true;
break;
}
}
}

// We are in active state, if the Download Controller is not idle and there is no extraction running
var active = !isDownloadControllerIdle() || extracting;
//check the active value we had in the last interval
var oldActive = getProperty("active", false) == true;
if (active != oldActive) {
//active state changed
//set new active state
setProperty("active", active, false);
if (!active) {
//we have been active in the last interval and are not active any more
playWavAudio(JD_HOME + "/themes/standard/org/jdownloader/sounds/captcha.wav");
}
}
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 23.04.2021 at 16:10.
Reply With Quote
  #187  
Old 23.04.2021, 19:33
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 615
Default

Alright. I have replaced the old one. Thank you very much!
__________________
Aktuelles Windows
Reply With Quote
  #188  
Old 23.04.2021, 19:44
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

You're welcome. In future the window will inform about what script/trigger is causing the issue
__________________
JD-Dev & Server-Admin
Reply With Quote
  #189  
Old 07.10.2022, 09:18
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 27
Smile Folderwatch VS these freezes jd2

Hi all

SOLVED BY UNCHECKING "Synchronous Execution of script" in each script that has this option in top of it

Thank you
Solution: Disable "Synchronous Execution of script" checkbox in the top panel of the script editor.

I used these scripts to skip links that was finished in the past,
https://board.jdownloader.org/showpo...4&postcount=18
https://board.jdownloader.org/showpo...3&postcount=24

but when I test adding several .craw files to folderwatch folder that have all old links to check if this work, jd2 freezes for long time

Only the first .craw job appear and then freeze with no any activity
jd2 cpu use gives 0 activity

Note" my history file has huge link number more than 30,000 and it may reach much much more

Notice\ I commented this line in the scripts,
// alert("Download Skipped: "" + url + "" is present in history file.");

I have to kill jd process via taskmanger
I tied to add a package manualy and it also freeze becuase it has old links,
Tried a package without old links goes ok
Thanks


SOLVED BY UNCHECKING "Synchronous Execution of script" in each script that has this option in top of it

Thank you

Can I remove dup links instead of disabling them via "link.enabled = false;????"

Last edited by georgegalily; 07.10.2022 at 10:44.
Reply With Quote
  #190  
Old 07.10.2022, 11:17
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

@georgegalily: Please create a log, see https://support.jdownloader.org/Know...d-session-logs
in case you cannot create log in that session, restart JDownloader and make sure to have the previous session/time range selected when creating the log. and then post logID here
__________________
JD-Dev & Server-Admin
Reply With Quote
  #191  
Old 07.10.2022, 12:21
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 27
Thumbs up

Quote:
Originally Posted by Jiaz View Post
@georgegalily: Please create a log, see **External links are only visible to Support Staff**...
in case you cannot create log in that session, restart JDownloader and make sure to have the previous session/time range selected when creating the log. and then post logID here
Thank you, I solved the issue as I stated in the post by

UNCHECKING "Synchronous Execution of script" in each script that has this option in top of it


But, can I remove dup links instead of disabling them via "link.enabled = false;????"
in this script,
code:


Code:
//Add your script here. Feel free to use the available api properties and methods
// If download link is present in history file, mark it as duplicae (add "#duplicatelink" to comment)
// Trigger required: Packagizer Hook

if (state == "AFTER") {
    var url = link.getURL();
    var historyFile = getPath(JD_HOME + "/cfg/history.txt");
    var history = historyFile.exists() ? readFile(historyFile) : "";

    if (history.indexOf(url) > -1) {
        var text = "#duplicatelink";
        var comment = link.getComment();
        comment = comment ? text + " " + comment : text;
        link.setComment(comment);
        link.enabled = false;

    }
}
Thanks

Last edited by georgegalily; 07.10.2022 at 12:26.
Reply With Quote
  #192  
Old 07.10.2022, 14:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

@georgegalily: Thanks for the feedback!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #193  
Old 07.10.2022, 14:54
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

Quote:
Originally Posted by georgegalily View Post
But, can I remove dup links instead of disabling them via "link.enabled = false;????"
in this script,
code:
maybe try to add the following lines after it
Code:
sleep(1000);
link.remove();
__________________
JD-Dev & Server-Admin
Reply With Quote
  #194  
Old 07.10.2022, 17:37
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 27
Exclamation

Quote:
Originally Posted by Jiaz View Post
maybe try to add the following lines after it
Code:
sleep(1000);
link.remove();
Does not work gives an errors
first one:
Java heap space
java.lang.OutOfMemoryError: Java heap space

second one:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function remove in object org.jdownloader.extensions.eventscripter.sandboxobjects.PackagizerLinkSandbox@1aea5885. (#17)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3629)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3613)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3634)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3650)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3714)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime. java:2233)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2 215)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1333)
at script(:17)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at org.jdownloader.scripting.JSHtmlUnitPermissionRestricter$SandboxContextFactory.doTopCall(JSHtmlUnitP ermissionRestricter.java:134)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115)
at net.sourceforge.htmlunit.corejs.javascript.Context.evaluateString(Context.java:1212)
at org.jdownloader.extensions.eventscripter.ScriptThread.evalUNtrusted(ScriptThread.java:322)
at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:182)
at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:162)
Reply With Quote
  #195  
Old 07.10.2022, 17:40
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

@georgegalily: can you show the complete script?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #196  
Old 07.10.2022, 17:45
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 27
Default

This is the targeted script mentioned above:
Code:
//Add your script here. Feel free to use the available api properties and methods
// If download link is present in history file, mark it as duplicae (add "#duplicatelink" to comment)
// Trigger required: Packagizer Hook

if (state == "AFTER") {
    var url = link.getURL();
    var historyFile = getPath(JD_HOME + "/cfg/history.txt");
    var history = historyFile.exists() ? readFile(historyFile) : "";

    if (history.indexOf(url) > -1) {
        var text = "#duplicatelink";
        var comment = link.getComment();
        comment = comment ? text + " " + comment : text;
        link.setComment(comment);
      //  link.enabled = false;
      sleep(1000)
      link.remove();
    }
}
This the even script export

Code:
[
 {
  "eventTrigger"         : "ON_ARCHIVE_EXTRACTED",
  "eventTriggerSettings" : {},
  "id"                   : 1636093853265,
  "name"                 : "",
  "script"               : null,
  "enabled"              : false
 },
 {
  "eventTrigger"         : "ON_NEW_LINK",
  "eventTriggerSettings" : {
                            "isSynchronous" : false
                           },
  "id"                   : 1665130121066,
  "name"                 : "Disable duplicate link in Lingrabber",
  "script"               : "/* \n    Disable duplicate link in Lingrabber list\n    Trigger required: A new link has been added\n*/\n\nvar link = crawledLink;\n\nif (link.availableState == \"ONLINE\") {\n    var file = getPath(JD_HOME + \"/cfg/history.txt\");\n\n    var lock = getModifyLock(file.name);\n    lock.writeLock();\n\n    var urls = getProperty(file.name, true);\n\n    if (urls == null) {\n        urls = file.exists() && readFile(file) || \"\";\n        setProperty(file.name, urls, true);\n    }\n\n    lock.writeUnlock();\n\n    if (urls) {\n        var url = link.contentURL || link.pluginURL;\n\n        if (link.host == \"youtube.com\") {\n            url = link.containerURL;\n        }\n\n        if (urls.indexOf(url) > -1) {\n            var text = \"#duplicatelink\";\n            var comment = link.comment;\n\n            if (comment) {\n                text = text + \" \" + comment;\n            }\n\n            link.comment = text;\n            link.enabled = false;\n        }\n    }\n}\n",
  "enabled"              : false
 },
 {
  "eventTrigger"         : "ON_PACKAGIZER",
  "eventTriggerSettings" : {
                            "isSynchronous" : false
                           },
  "id"                   : 1665128070287,
  "name"                 : "mark it as duplicae",
  "script"               : "//Add your script here. Feel free to use the available api properties and methods\n// If download link is present in history file, mark it as duplicae (add \"#duplicatelink\" to comment)\n// Trigger required: Packagizer Hook\n\nif (state == \"AFTER\") {\n    var url = link.getURL();\n    var historyFile = getPath(JD_HOME + \"/cfg/history.txt\");\n    var history = historyFile.exists() ? readFile(historyFile) : \"\";\n\n    if (history.indexOf(url) > -1) {\n        var text = \"#duplicatelink\";\n        var comment = link.getComment();\n        comment = comment ? text + \" \" + comment : text;\n        link.setComment(comment);\n      //  link.enabled = false;\n      sleep(1000)\n      link.remove();\n    }\n}",
  "enabled"              : false
 },
 {
  "eventTrigger"         : "DOWNLOAD_TABLE_CONTEXT_MENU_BUTTON",
  "eventTriggerSettings" : {},
  "id"                   : 1665128070283,
  "name"                 : "Move to history",
  "script"               : "// Add finished download links from selection to history, and remove them from the list\n// Tirgger required: Downloadlist Contextmenu Button Pressed\n// Customize downloadlist context menu > Add new \"Eventscripter Trigger\" button > Rename it to \"Move to history\" (without quotes) > Change Icon (optional)\n\nif (name == \"Move to history\") {\n    var file = getPath(JD_HOME + \"/cfg/history.txt\"),\n        urls = file.exists() ? readFile(file) : \"\",\n        newUrls = \"\",\n        url, data, text, comment;\n\n    dlSelection.links.forEach(function(link) {\n        if (link.finished) {\n            url = link.contentURL || link.pluginURL;\n\n            if (urls.indexOf(url) == -1) {\n                newUrls += url + \"\\r\\n\";\n                link.remove();\n            }\n        }\n    });\n\n    if (newUrls.length) {\n        data = \"Added from the downloadlist list on \" + Date().toString().substring(4, 24) + \"\\r\\n\";\n        data += newUrls + \"\\r\\n\";\n        writeFile(file, data, true);\n\n        getAllCrawledLinks().forEach(function(link) {\n            if (link.availableState == \"ONLINE\") {\n                url = link.contentURL || link.pluginURL;\n                text = \"#duplicatelink\";\n                comment = link.comment || \"\";\n                \n                if (comment.indexOf(text) == -1 && (urls + newUrls).indexOf(url) > -1) {\n                    link.comment = comment ? text + \" \" + comment : text;\n                }\n            }\n        });\n    }\n}\n",
  "enabled"              : true
 },
 {
  "eventTrigger"         : "ON_DOWNLOAD_CONTROLLER_START",
  "eventTriggerSettings" : {
                            "isSynchronous" : false
                           },
  "id"                   : 1665128070289,
  "name"                 : "duplicatelinkch",
  "script"               : "//Add your script here. Feel free to use the available api properties and methods\n// Skip link if it present in download history (has \"#duplicatelink\" in comment)\n// To download the file (prevent skipping), remove \"#duplicatelink\" from comment\n// Trigger required: A Download Started\n\nvar comment = link.getComment() || \"\";\n\nif (comment.indexOf(\"#duplicatelink\") > -1) {\n    var url = link.getContentURL() || link.getPluginURL();\n    link.setSkipped(true);\n  //  alert(\"Download Skipped: \\\"\" + url + \"\\\" is present in history file.\");\n}",
  "enabled"              : true
 },
 {
  "eventTrigger"         : "LINKGRABBER_TABLE_CONTEXT_MENU_BUTTON",
  "eventTriggerSettings" : {},
  "id"                   : 1665128070285,
  "name"                 : "Move to historyLG",
  "script"               : "// Add selected linkgrabber links to history, and remove them from the list\n// Tirgger required: Linkgrabber Contextmenu Button Pressed\n// Customize linkgrabber context menu > Add new \"Eventscripter Trigger\" button > Rename it to \"Move to history\" (without \nquotes) > Change Icon (optional)\n\nif (name == \"Move to history\") {\n    var historyFile = getPath(JD_HOME + \"/cfg/history.txt\");\n    if (!historyFile.exists()) writeFile(historyFile, \"\", true);\n    var history = readFile(historyFile);\n\n    var linkUrls = [];\n    var linkIds = [];\n\n    var removeLinks = function(linkIds) {\n        callAPI(\"linkgrabberv2\", \"removeLinks\", linkIds, []);\n    }\n\n    lgSelection.getLinks().forEach(function(link) {\n        var url = link.getUrl();\n        var id = link.getUUID();\n\n        if (history.indexOf(url) == -1) linkUrls.push(url);\n        linkIds.push(id);\n    })\n\n    if (linkUrls.length) {\n        data = \"Added from the lingkrabber list on \" + Date().toString().substring(4, 24) + \"\\r\\n\";\n        data += linkUrls.join(\"\\r\\n\") + \"\\r\\n\\r\\n\";\n        writeFile(historyFile, data, true);\n    }\n\n    if (linkIds.length) removeLinks(linkIds);\n}",
  "enabled"              : true
 }
]

Last edited by georgegalily; 07.10.2022 at 17:54.
Reply With Quote
  #197  
Old 07.10.2022, 17:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

@georgegalily
Please try this one
Code:
if (state == "AFTER") {
    var url = link.getURL();
    var historyFile = getPath(JD_HOME + "/cfg/history.txt");
    var lock = getModifyLock("history");
    var isDuplicate = false;
    lock.writeLock();
    try {
        var history = historyFile.exists() ? readFile(historyFile) : "";
        isDuplicate = history.indexOf(url) > -1;
        history = null;
    } finally {
        lock.writeUnlock();
    }
    if (isDuplicate) {
        var text = "#duplicatelink";
        var comment = link.getComment();
        comment = comment ? text + " " + comment : text;
        link.setComment(comment);
        sleep(1000);
        link.getCrawledLink().remove();
    }
}
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 07.10.2022 at 17:57.
Reply With Quote
  #198  
Old 07.10.2022, 17:58
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 27
Default

This shows "java.lang.OutOfMemoryError: Java heap space"

Last edited by georgegalily; 07.10.2022 at 18:03.
Reply With Quote
  #199  
Old 07.10.2022, 17:59
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

@georgegalily: please see updated script, had to update it multiple times
__________________
JD-Dev & Server-Admin
Reply With Quote
  #200  
Old 07.10.2022, 18:04
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,044
Default

Quote:
Originally Posted by georgegalily View Post
This shows "java.lang.OutOfMemoryError: Java heap space"
how large is your history.txt file?
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 12:37.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.