JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #161  
Old 17.03.2021, 09:13
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

I had added YouTube links to the linkgrabber, removed the ones being marked as dups. Left the not dups in the grabber closed JD and started it the next day. Now all of the links in the grabber were marked as dups. Why is that?



I searched for some of the (dup) URLs in history.txt but I did not find any.
__________________
Aktuelles Windows
Reply With Quote
  #162  
Old 18.03.2021, 15:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Amiganer View Post
(I'm a littlebit confused, what script is which one).
Me too. Will let you know if I am able to figure it out.
Reply With Quote
  #163  
Old 18.03.2021, 15:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Dockel View Post
How could I avoid such messages:
They show up when I add a file to the history.
Going by the the title of the dialog box in your screenshot, looks like it was a temp script provided for trouble shooting and not required to add links to history file. You can just disable it.

Quote:
Originally Posted by Dockel View Post
I had added YouTube links to the linkgrabber, removed the ones being marked as dups. Left the not dups in the grabber closed JD and started it the next day. Now all of the links in the grabber were marked as dups. Why is that?

I searched for some of the (dup) URLs in history.txt but I did not find any.
Links are marked as duplicate only if a matching url is found in the 'history' file OR the download list (including download list to match dupes was implemented on your request some time back). A matching url was found in either of those lists at the time of dupe check.
Reply With Quote
  #164  
Old 18.03.2021, 15:36
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Quote:
Going by the the title of the dialog box in your screenshot, looks like it was a temp script provided for trouble shooting and not required to add links to history file. You can just disable it.
Done, thank you.

Quote:
Links are marked as duplicate only if a matching url is found in the 'history' file OR the download list (including download list to match dupes was implemented on your request some time back). A matching url was found in either of those lists at the time of dupe check.
Those were new links, never added before (and I manually searched in the history.txt for some, found any, if they had been in the downloadlist they would have been marked red in the linkgrabber, so I would have seen it), so actually I would think something else must have caused that. Well, may be I made a mistake. OK, may be it will never happen again.

Many thanks!
__________________
Aktuelles Windows
Reply With Quote
  #165  
Old 18.03.2021, 16:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Dockel View Post
Well, may be I made a mistake.
Not necessarily. It could also be a bug, in which case, it might happen again. Please feel free to report back if it does.
Reply With Quote
  #166  
Old 18.03.2021, 17:13
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

I will do so, thank you!
__________________
Aktuelles Windows
Reply With Quote
  #167  
Old 18.03.2021, 21:41
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

The same just happened again but without closing and starting JD, any idea why and when, the links are disabled, marked es dups:


May be it has anything to do with the reconnection? During, before or after the last reconnection, however, nothing happened to these links.
__________________
Aktuelles Windows

Last edited by Dockel; 18.03.2021 at 21:50.
Reply With Quote
  #168  
Old 18.03.2021, 22:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Dockel View Post
The same just happened again but without closing and starting JD, any idea why and when, the links are disabled, marked es dups:

May be it has anything to do with the reconnection? During, before or after the last reconnection, however, nothing happened to these links.
Going by the the number of comments in your screenshot (2 in 1st and 4 is 2nd), it looks like the same script is running mulitple times or two similar scripts are running twice. Some crawling activity might be triggering the script.

If you provide me (in JD Chat) the current scripts value from advanced settings, I can take a look at it.
Reply With Quote
  #169  
Old 19.03.2021, 12:12
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

I couldn't reproduce the issue with (really) new links (of files definitely not being downloaded before). I will keep on trying.

It seems the long urls are still added wihtout shortening them. So they still look like this one:

**External links are only visible to Support Staff****External links are only visible to Support Staff**

Could the script add the time stamp (of the time the urls were added to history) like it was some time / weeks before? Although there was some drawback of doing that, if I remember it right.

Edit: now the same issue occurred again.
__________________
Aktuelles Windows

Last edited by Dockel; 19.03.2021 at 15:06.
Reply With Quote
  #170  
Old 21.03.2021, 10:35
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

@Dockel: Contact me in IRC when you are free. I will chek the url issue and also add an option to include timestamp. But I will not be able to fix the first issue mentioned in the previous post, unless I know how to consistently reproduce the issue.
Reply With Quote
  #171  
Old 31.03.2021, 11:28
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

When I moved to history.txt some links from the download window suddenly this message popped up:


Quote:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "getExtractionStatus" of null (#19)
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.undefCallError(ScriptRuntime.java:3664)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime. java:2221)
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(:19)
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:318)
at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:180)
at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:160)
I restarted JD.

When I then wanted to move links to the history from the download list they were not added anymore. Suddenly it sometimes is working, the URLs are added again, but now the URLs do not appear to be shortend anymore in the history.

Moving the URLs to the history from the link grabber seems to work always.
Is there anything I could do?
__________________
Aktuelles Windows

Last edited by Dockel; 31.03.2021 at 11:47.
Reply With Quote
  #172  
Old 31.03.2021, 12:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@Dockel: The script tries to call getExtractionStatus method of null element. I think the script is missing null check somewhere
__________________
JD-Dev & Server-Admin
Reply With Quote
  #173  
Old 31.03.2021, 13:19
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

OK, strange it is occurring suddenly.
__________________
Aktuelles Windows
Reply With Quote
  #174  
Old 31.03.2021, 13:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

Can you show the script, then I can check
__________________
JD-Dev & Server-Admin
Reply With Quote
  #175  
Old 31.03.2021, 13:24
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

@Dockel: Not caused by history scripts. They do not use that particular call. Most likely caused by JD 'example' scripts.

I have tested the history scripts from the github url, and they appear to be working fine and also saving short urls.

If in doubt, find me in JD Chat.
Reply With Quote
  #176  
Old 31.03.2021, 13:24
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Yes, of course, but I am not sure which script it is, let my try to find it.
__________________
Aktuelles Windows
Reply With Quote
  #177  
Old 31.03.2021, 13:26
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Actually it must be this one:

Quote:
/*
Move selected links from linkgrabber list to history file
Trigger required: Linkgrabber Contextmenu Button Pressed
Customize linkgrabber context menu > Add new "Eventscripter Trigger" button > Rename it to "Move to history" (without quotes) > Change Icon (optional)
*/

if (name = "Move to history") {
var file = getPath(JD_HOME + "/cfg/history.txt");

var lock = getModifyLock(file.name);
lock.writeLock();

var urls = getProperty(file.name, true) || file.exists() && readFile(file) || "";
var unique = "";

lgSelection.getLinks().forEach(function(link) {
if (link.availableState == "ONLINE") {
var downloadLink = link.downloadLink;

if (downloadLink) {
var url = downloadLink.contentURL || downloadLink.pluginURL;

if (link.host == "youtube.com") {
url = link.containerURL;
}

if (urls.indexOf(url) == -1) {
unique += url + "\r\n";
}

link.remove();
}
}
})

if (unique) {
var date = Date().substr(4, 20);
writeFile(file, date + "\r\n" + unique + "\r\n", true);
}

setProperty(file.name, urls += unique, true);
lock.writeUnlock();
}
__________________
Aktuelles Windows
Reply With Quote
  #178  
Old 31.03.2021, 13:32
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

That's not the script causing this. It must be a script using getExtractionStatus method
__________________
JD-Dev & Server-Admin
Reply With Quote
  #179  
Old 31.03.2021, 13:44
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Yes, sorry, mgpai is just searching for the error in all of the scripts. I do not have any idea which one it might be.
__________________
Aktuelles Windows
Reply With Quote
  #180  
Old 31.03.2021, 15:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@Dockel: Export Settings->Advanced Settings->EventScripter.scripts and send to support@jdownloader.org
easier to debug when we know what scripts you are using
__________________
JD-Dev & Server-Admin
Reply With Quote
  #181  
Old 31.03.2021, 16:44
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
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 16:47.
Reply With Quote
  #182  
Old 02.04.2021, 02: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, 19:46
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
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, 11:11
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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, 14:52
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Yes, of course, thank you very much! Just done.
__________________
Aktuelles Windows
Reply With Quote
  #186  
Old 23.04.2021, 17:08
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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 17:10.
Reply With Quote
  #187  
Old 23.04.2021, 20:33
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Alright. I have replaced the old one. Thank you very much!
__________________
Aktuelles Windows
Reply With Quote
  #188  
Old 23.04.2021, 20:44
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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, 10:18
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 29
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 11:44.
Reply With Quote
  #190  
Old 07.10.2022, 12:17
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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, 13:21
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 29
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 13:26.
Reply With Quote
  #192  
Old 07.10.2022, 15:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@georgegalily: Thanks for the feedback!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #193  
Old 07.10.2022, 15:54
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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, 18:37
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 29
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, 18:40
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@georgegalily: can you show the complete script?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #196  
Old 07.10.2022, 18:45
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 29
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 18:54.
Reply With Quote
  #197  
Old 07.10.2022, 18:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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 18:57.
Reply With Quote
  #198  
Old 07.10.2022, 18:58
georgegalily georgegalily is offline
Super Loader
 
Join Date: Oct 2018
Posts: 29
Default

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

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

@georgegalily: please see updated script, had to update it multiple times
__________________
JD-Dev & Server-Admin
Reply With Quote
  #200  
Old 07.10.2022, 19:04
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
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 21:25.
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 - 2024, Jelsoft Enterprises Ltd.