JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1441  
Old 04.07.2020, 04:29
woriamu woriamu is offline
Junior Loader
 
Join Date: Jun 2020
Posts: 12
Default

Quote:
Originally Posted by mgpai View Post
Note: This script will delete links from the download list. Keep a backup of link list before running the script.

Code:
// Reset finished link, if size is zero bytes
// Trigger: A Download Stopped

if (link.finished && !link.bytesTotal) {
    link.reset();
}
It didn't work -- I got this error message.

Code:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "link" is not defined. (#4)
	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.notFoundError(ScriptRuntime.java:3683)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.name(ScriptRuntime.java:1690)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1622)
	at script(:4)
	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(JSHtmlUnitPermissionRestricter.java:119)
	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:288)
	at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:180)
	at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:155)
Thank you for helping me with this btw!! Not sure if this is important, but I changed the trigger to JDownloader started because I couldn't make anything happen with the trigger you gave. The above message came as I opened up JDownloader.
Reply With Quote
  #1442  
Old 04.07.2020, 07:05
tisurame tisurame is offline
Modem User
 
Join Date: Jul 2020
Posts: 2
Default

Hi. Anyone else using Linux?

I'm trying to create a very simple script after file extraction in order to upload the content to the cloud using a software called Rclone, that can be executed using the terminal (command line) with the following command:

Code:
rclone move /home/user/Downloads/extracted/ gdrive:

I already tried to create a bash script.sh like this...

Code:
#!/bin/bash
/usr/bin/rclone move /home/user/Downloads/extracted/ gdrive:

Then, I tried to do a test run from Jdownloader using the following*lines:


Code:
var myScript = "/home/thiago/script.sh";
callSync(myScript);

But it didn't work. It works just fine using "/home/thiago/script.sh" on the terminal command prompt, but not running inside Jdownloader doing a test run.

I already gave an execute permission on my bash script using "chmod +x script.sh". And it's still not working.

I also made a really simple script like:


Code:
callSync("/home/thiago/makemkv.sh");

Which will only launch a software called makemkv and it's not working. It works using the command line outside Jdownloader, though.

Actually, it seems even the example scripts are not working on Linux (Ubuntu 20.04).

Anyone could please help me?

Last edited by tisurame; 04.07.2020 at 07:21.
Reply With Quote
  #1443  
Old 04.07.2020, 07:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by woriamu View Post
... I changed the trigger to JDownloader started because I couldn't make anything happen with the trigger you gave. The above message came as I opened up JDownloader.
It throws an error since the trigger you are using does not return a 'link' object. You have to use the one specified in the script, which will execute the script when a download is 'finished'. If it still does not work, find me in JD Chat:

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #1444  
Old 04.07.2020, 07:28
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by tisurame View Post
... Actually, it seems even the example scripts are not working on Linux.
Try using the 'alert' method to debug. If it turns out to be an OS issue, devs/user in the forum familiar with Linux should be able to point you in the right direction. You can also find be in JD Chat (link in above post) if you think I can help you with the troubleshooting.

Example:
Code:
var result = callSync("/home/thiago/makemkv.sh");
alert(result);
Reply With Quote
  #1445  
Old 04.07.2020, 13:07
-Whiplash- -Whiplash- is offline
Modem User
 
Join Date: Jul 2020
Posts: 4
Default

Hey guys, I don't know Java at all so I'd like some help.

I need a script that stops downloading and then resumes (NOT RESETS) links from a certain website every 5 minutes.

I'm having a major issue with this website, where it constantly says the files are unavailable when they actually are (can confirm this cause I can hit resume and then they will resume downloading.) currently I'm doing this manually but this is just gonna take forever.

Thanks in advance if anyone can help me.
Reply With Quote
  #1446  
Old 04.07.2020, 17:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by -Whiplash- View Post
... I'm having a major issue with this website, where it constantly says the files are unavailable when they actually are ...
Better to see if it can be fixed at the plugin level. If you provide a log the developers might be able to check/fix it.
Reply With Quote
  #1447  
Old 04.07.2020, 22:19
woriamu woriamu is offline
Junior Loader
 
Join Date: Jun 2020
Posts: 12
Default

Quote:
Originally Posted by mgpai View Post
It throws an error since the trigger you are using does not return a 'link' object. You have to use the one specified in the script, which will execute the script when a download is 'finished'. If it still does not work, find me in JD Chat:

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Okay I see. So if I'm understanding this correctly, this script will not work retroactively but will prevent this from happening in the future? Because if so thanks a ton because this has been a recurring problem and probably will happen in the future. I would need an additional script that can fix the previous links that went through this though. Thanks again.
Reply With Quote
  #1448  
Old 05.07.2020, 07:30
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by woriamu View Post
I would need an additional script that can fix the previous links that went through this though.
Please reset such existing links manually by using GUI filter/sort feature. You will need to do it only once since such links will be automatically reset by the script in future.
Reply With Quote
  #1449  
Old 05.07.2020, 11:02
JimmyRompeolas JimmyRompeolas is offline
Modem User
 
Join Date: Jul 2020
Posts: 1
Default

Hi all,

First of all, huge thanks to the devs and mgpai for your software and effort helping with the scripts!

I'm trying to write a simple script that goes through the links in the download list and just starts them and after at least a single byte has been downloaded, it disables it, deletes what's been downloaded and jumps to the next link.

I've tried using the following script but since the download start is inconsistent, I would need a really long "sleep" in order to make sure the download has started and the conditions are met.

Maybe I'm completely wrong in my approach, so any help would be greatly appreciated!

Last edited by JimmyRompeolas; 05.07.2020 at 15:27. Reason: Removed code due to potential abuse
Reply With Quote
  #1450  
Old 05.07.2020, 11:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by JimmyRompeolas View Post
... script that goes through the links in the download list and just starts them and after at least a single byte has been downloaded, it disables it, deletes what's been downloaded and jumps to the next link.
I have declined several such requests in the past, since file hosters can be subject to abuse with such scripts. Naturally, users are always free to write thier own (as you pretty much have).

Feel free to find me in JD Chat if you need any help with it.
Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #1451  
Old 05.07.2020, 21:28
woriamu woriamu is offline
Junior Loader
 
Join Date: Jun 2020
Posts: 12
Default

Quote:
Originally Posted by mgpai View Post
Please reset such existing links manually by using GUI filter/sort feature. You will need to do it only once since such links will be automatically reset by the script in future.
Would it be possible to make a script that adds the comment "zero bytes" (or anything really) to any link where the size = 0 bytes? That would make manually resetting them much easier as I have hundreds of 0 byte links scattered across thousands of downloads among hundreds of packages. I could just use the search for all the links with that comment and then CTLR+A and reset them. If not thanks again and I'll just get to work manually resetting them all lol
Reply With Quote
  #1452  
Old 06.07.2020, 06:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by woriamu View Post
... I have hundreds of 0 byte links scattered across thousands of downloads among hundreds of packages ...
Note: This script will delete links from the download list. Keep a backup of link list before running the script.

Code:
// Reset finished link, if size is zero bytes
// Trigger: JDownloader Started

getAllDownloadLinks().forEach(function(link) {
    if (link.finished && !link.bytesTotal) {
        link.reset();
    }
})

Unlike the other script which queries a single link, this queries all links, which will use more system resources each time it is executed, especially if you lot of links in the list. So disable it once the existing links in the list are reset.
Reply With Quote
  #1453  
Old 11.07.2020, 02:21
heyfernand heyfernand is offline
JD Alpha
 
Join Date: Aug 2017
Posts: 22
Default

Hi folks

I use a program called MKVToolNix to REMUX .mp4 files to .mkv that I would like to automate, this is the code of the app it supports CMD but for some reason the CMD window always stays open instead of closing automatically

Code:
"C:\mkvtoolnix\mkvmerge.exe" --ui-language en --output ^"C:\outputfilename.mkv^" --language 0:und --language 1:eng ^"^(^" ^"C:\inputfilename.mp4^" ^"^)^" --track-order 0:0,0:1
what would be a script that triggers
if after the download is successful
if it's .mp4 extension

and executes the commands to remux whilst properly keeping the original name of the file?

thank youuu
Reply With Quote
  #1454  
Old 11.07.2020, 15:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by heyfernand View Post
... use ... MKVToolNix to REMUX .mp4 files to .mkv ... after the download is successful ... if it's .mp4 extension ... whilst properly keeping the original name of the file ...
Code:
// Remux 'mp4' to 'mkv'
// Trigger: A Download Stopped

if (link.finished) {
    var file = link.downloadPath,
        type = getPath(file).extension,
        out = file.replace(type, "mkv"),
        mkvmerge = "c:\\mkvtoolnix\\mkvmerge.exe";

    if (type == "mp4") {
        callSync(mkvmerge, "-o", out, file);
    }
}
Reply With Quote
  #1455  
Old 12.07.2020, 09:07
heyfernand heyfernand is offline
JD Alpha
 
Join Date: Aug 2017
Posts: 22
Default

thank you so much Mgpai, worked flawlessly!

I noticed the original .mp4 file remained, my guess is that I would have to run a second separate script to delete it right?

what would be the script to move the file to recycle bin OR delete if recycle bin isn't possible
if .mp4
after interval 1200 seconds

whilst keeping it inside Downloads Tab for historical purposes, I need it to remain inside the downloads tab to avoid downloading it twice, so It will be deleted only externally

thanks in advance
Reply With Quote
  #1456  
Old 12.07.2020, 10:27
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

Quote:
Originally Posted by heyfernand View Post
I noticed the original .mp4 file remained ...
Why would it not be? You OP does not include any explicit request for deletion of the source file.

You can use the program options (add it to the existing program parameters in script) to delete it. If you need any help adding it the script, find me in JD Chat.
Reply With Quote
  #1457  
Old 12.07.2020, 10:58
heyfernand heyfernand is offline
JD Alpha
 
Join Date: Aug 2017
Posts: 22
Default

Quote:
Originally Posted by mgpai View Post
Why would it not be? You OP does not include any explicit request for deletion of the source file.

You can use the program options (add it to the existing program parameters in script) to delete it. If you need any help adding it the script, find me in JD Chat.
you're right I forgot to mention the deletion of original file after 1200 seconds in the OP. I'll enter the chat. thanks so much!!!!
Reply With Quote
  #1458  
Old 14.07.2020, 15:59
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 54,410
Default

@mgpai
I'm currently in the process of finally adding some helpful help articles to our knowledge database / fixing / deleting older ones.
I know that this thread contains a script that basically does "Auto-Update JD when it is not in use/downloading".
Can you please point me to the right direction?
I would like to add a hint to this script to the basic headless installation instructions:
https://support.jdownloader.org/Know...bedded-devices

Also, if you want to, maybe you can modify the script so it has the following features:
- Auto-Update every X hours regardless whether or not downloads are running
- Only update if no downloads are running

I think this will be helpful for a lot of users (including me lol) running JD on a server where it is running permanently.

If you got more ideas regarding useful help articles, just let me know

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager
How to create a log || Wie man einen Log erstellt
Captcha FAQ EN || Captcha FAQ DE || Erste Schritte & Tutorials
JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenver​ein kein Ort für Amoklaufide​en ist
Reply With Quote
  #1459  
Old 15.07.2020, 10:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 939
Default

@psp: Have included an option to restart after 'x' hours (Disabled by default).

For GUI:
Code:
// 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");
    }
}

For Headless:
Code:
[ {
  "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
} ]

If I have something useful to add to the articles, will definitely share my thoughts.
Reply With Quote
  #1460  
Old 15.07.2020, 15:27
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 54,410
Default

Thanks!

Soon after I will have posted this post, your auto-update script will be added to our knowledgebase!

From now on we also have a separate Event Scripter category in our Knowledge-Base.

It is primarily there to link existing scripts but as scripts are usually made by users, we will still mainly use our forum for them.
We will put some popular/useful scripts directly into our knowledgebase.

-psp-
EDIT

I got it linked HERE.
__________________
JD Supporter, Plugin Dev. & Community Manager
How to create a log || Wie man einen Log erstellt
Captcha FAQ EN || Captcha FAQ DE || Erste Schritte & Tutorials
JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenver​ein kein Ort für Amoklaufide​en ist

Last edited by pspzockerscene; 15.07.2020 at 15:41.
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 07:08.
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 - 2020, Jelsoft Enterprises Ltd.