JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1441  
Old 04.07.2020, 05: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, 08: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 08:21.
Reply With Quote
  #1443  
Old 04.07.2020, 08:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 08:28
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 14: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, 18:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 23: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, 08:30
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 12: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 16:27. Reason: Removed code due to potential abuse
Reply With Quote
  #1450  
Old 05.07.2020, 12:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 22: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, 07:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 03: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, 16:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 10: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, 11:27
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 11: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, 16:59
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 70,921
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

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?
Reply With Quote
  #1459  
Old 15.07.2020, 11:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 16:27
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 70,921
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

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?

Last edited by pspzockerscene; 15.07.2020 at 16:41.
Reply With Quote
  #1461  
Old 16.07.2020, 00:00
tisurame tisurame is offline
Modem User
 
Join Date: Jul 2020
Posts: 2
Default

Quote:
Originally Posted by mgpai View Post
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);
Thanks! The problem, after all, was because I was using a version installed using the snap store. Using the regular version solved the problem.
Reply With Quote
  #1462  
Old 16.07.2020, 18:36
LongDongGold LongDongGold is offline
Junior Loader
 
Join Date: Apr 2020
Posts: 12
Default

Hi.

So I got Event Scripter installed now and I would like JD to do a few things after finished downloads but only to certain files.

I want to cut out the first 7 seconds of any video downloaded from saidwebsite

I have the ffmpeg command line in a .bat file now that I run inside the folder with the videos.

I also use the packagizer in JD for saidwebsite so files are grabbed and downloaded into specific folder - <jd:prop:username>

I would be very happy if I could automatize some of all this manual work.

After download what i specifically want to happen is 7 first seconds cut out of the video & the new file must overwrite the old file in the folder

Then I only have the renaming of files to do manually afterwards - but if possible I would like to have that automated too

I use bulk rename utility right now and I have a template that:
removing chars:
Code:
///#,_-¦¡/¿'.;()//
and removing words:
Code:
480p 4k 720p 1080p 1440p 2160p
It also capitalize the title.

I would also like to have the file prefix to be the performers name & I would like to have the performers username at the end of the title removed.

It sounds like a lot - I know - and it is a lot of manual work right now.

Any help getting this more automatic is really appreciated.

Last edited by raztoki; 17.07.2020 at 00:44.
Reply With Quote
  #1463  
Old 24.07.2020, 08:30
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Code:
var filePaths = archive.getExtractionLog().match(/\(FileArchiveFile\)File:[^|]+/g).map(function(filePath) {
    return filePath.replace(/.+?:(.+)/, "$1");
});

alert(filePaths.join("\n"));
Have idea how make distinguish between manual and automatical extract?
i make so: var links = archive.getDownloadLinks() || [];

And then if links.length > 0 I take it for automatical extract otherwise I take it for manual extract.
Is safe? Or better idea?
Because your code must only run when manual extract.

Last edited by sherbee; 24.07.2020 at 10:36.
Reply With Quote
  #1464  
Old 24.07.2020, 12:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
Have idea how make distinguish between manual and automatical extract?
You can modify the code to also get file paths of archives with links:
Code:
var getArchiveFiles = function() {
    return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
        return string.replace(/.+?:(.+)/, "$1");
    });
}

Or use it with existing archive methods:
Code:
var getArchiveFiles = function() {
    var archiveLinks = archive.getDownloadLinks();

    if (archiveLinks) {
        return archiveLinks.map(function(link) {
            return link.getDownloadPath();
        })
    } else {
        return archive.getExtractionLog().match(/\(FileArchiveFile\)File:[^|]+/g).map(function(string) {
            return string.replace(/.+?:(.+)/, "$1");
        });
    }
}

Common usage for both functions:
Code:
getArchiveFiles().forEach(function(file) {
    // Do something with each archive file
    // alert(file);
});
Reply With Quote
  #1465  
Old 25.07.2020, 10:07
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
You can modify the code to also get file paths of archives with links:
Code:
var getArchiveFiles = function() {
    return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
        return string.replace(/.+?:(.+)/, "$1");
    });
}
But when use with manual extract it gives: 'TypeError: Cannot call method "match" of null' for this line of code:

Code:
return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
What I do is open 1 single package for extract, not multi archive or something. Then it extract, but then show this error.

I don't know what is wrong for automatic extraction after download no such error.

Last edited by sherbee; 25.07.2020 at 10:09.
Reply With Quote
  #1466  
Old 25.07.2020, 10:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
But when use with manual extract it gives: 'TypeError: Cannot call method "match" of null' for this line of code...
I am unable to reproduce the error. Open the extraction log to check if it matches the regex pattern used in the script (just in case if it is language dependent), and modify if necessary.
Reply With Quote
  #1467  
Old 25.07.2020, 12:51
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
I am unable to reproduce the error. Open the extraction log to check if it matches the regex pattern used in the script (just in case if it is language dependent), and modify if necessary.
I check. First error was 7zip binding made error. I put new 7zip binding in folder now no more 7zip error.

But still 'TypeError: Cannot call method "match" of null''

So I look in log folder. Interesting: 1s time manual extract => Error. When retry same file => No error.

Other error happen: Wrapped org.appwork.exceptions.WTFException: java.io.FileNotFoundException:

Now I see there is /open folder in log folder. When extracting log goes in open folder then moved in extracting folder.
So I think null-error happen when log is still in 'open' folder so it cannot find it? Maybe this is reason? Or it wants find it in 'open' folder and it already in 'extracting' folder?
Reply With Quote
  #1468  
Old 25.07.2020, 14:30
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
... So I think null-error happen when log is still in 'open' folder so it cannot find it? ...
Quite possible. I guess you will have to wait for the developers to confirm, and fix it if necessary. In the meanwhile, you can try this workaround.

Code:
var getArchiveFiles = function() {
    var log = archive.getExtractionLog();
    var count = 60; // max. seconds to wait for log

    while (!log && count) {
        log = archive.getExtractionLog();
        count--;
        sleep(1000);
    }

    if (log) {
        return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
            return string.replace(/.+?:(.+)/, "$1");
        });
    } else {
        alert("Log file for archive \"" + archive.getName() + "\" not found.");
        return [];
    }
}

getArchiveFiles().forEach(function(archiveFile) {
    // Do something with each archive file
    // alert(archiveFile);
})
Reply With Quote
  #1469  
Old 25.07.2020, 16:28
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Quite possible. I guess you will have to wait for the developers to confirm, and fix it if necessary. In the meanwhile, you can try this workaround.

Code:
var getArchiveFiles = function() {
    var log = archive.getExtractionLog();
    var count = 60; // max. seconds to wait for log

    while (!log && count) {
        log = archive.getExtractionLog();
        count--;
        sleep(1000);
    }

    if (log) {
        return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
            return string.replace(/.+?:(.+)/, "$1");
        });
    } else {
        alert("Log file for archive \"" + archive.getName() + "\" not found.");
        return [];
    }
}

getArchiveFiles().forEach(function(archiveFile) {
    // Do something with each archive file
    // alert(archiveFile);
})
No works yet.

Still geting error like: 'Wrapped org.appwork.exceptions.WTFException: java.io.FileNotFoundException: \jdownloader\logs\extracting\*.txt'

But it should report error message: 'Log file for archive "" + archive.getName() + "" not found.' Right?

So log check not works?
Reply With Quote
  #1470  
Old 25.07.2020, 17:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
Still geting error like: 'Wrapped org.appwork.exceptions.WTFException: java.io.FileNotFoundException: \jdownloader\logs\extracting\*.txt'

But it should report error message: 'Log file for archive "" + archive.getName()
+ "" not found.' Right?
That message will be displayed only on 'method of null' error (if 'log' is 'null'). This seems to be a different error which is thrown right at the beginning when executing "archive.getExtractionLog()" method, which disables the script and prevents the rest of the code from being executed.

Alternatively, you can use while loop to check the folder contents of 'open', and execute the script only after it is empty. It might then even work even without 'log = null' check.

Unfortunately I cannot test it since I am unable to reproduce the error. Feel free to find me in JD Chat if need any help with the script/troubleshooting.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #1471  
Old 26.07.2020, 07:52
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
That message will be displayed only on 'method of null' error (if 'log' is 'null'). This seems to be a different error which is thrown right at the beginning when executing "archive.getExtractionLog()" method, which disables the script and prevents the rest of the code from being executed.

Alternatively, you can use while loop to check the folder contents of 'open', and execute the script only after it is empty. It might then even work even without 'log = null' check.

Unfortunately I cannot test it since I am unable to reproduce the error. Feel free to find me in JD Chat if need any help with the script/troubleshooting.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
I have new error now.
Code:
getArchiveFiles().forEach(function(archiveFile) {
    // Do something with each archive file
    alert(archiveFile);
})
gives wrong name.
In single cases for example I manual extract file xyz.7z. But 'alert(archiveFile)' gives filename: xyz_2.7z.
When check I see file package name xyz with file name xyz_2.7z alrready in download list from earlier time.
So function not gives name from actual extract, but from some extraction earlier.
I can see in log from actual extract, that correct file xyz.7z i have select.

That is not good.
I see 3 times now. Always same: Extract file filename.7z manual. but name shows filename_2.7z and after check I see file with filename_2.7z already in download list from time ago. Actual log but show filename.7z.

Maybe it same reasen that makes bug I have report: https://board.jdownloader.org/showpo...54&postcount=8

It's problem because I take 'archiveFile' for move file automaticall after extract. So when it gives wrong filename, file cannot find to move.

Last edited by sherbee; 26.07.2020 at 07:58.
Reply With Quote
  #1472  
Old 26.07.2020, 09:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
... Maybe it same reasen that makes bug I have report ...
Looks like it is related to the issue you reported. If the API method returns the wrong log, nothing can be done in the script to verify/rectify it.

If you can run a local file server, you can load the archive files to JD and generate 'local' download links which can be automatically extracted. While it may not solve the wrong 'log' or 'status' problem, you should be able to move the links using a script, without any issues.
Reply With Quote
  #1473  
Old 26.07.2020, 10:22
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Looks like it is related to the issue you reported. If the API method returns the wrong log, nothing can be done in the script to verify/rectify it.

If you can run a local file server, you can load the archive files to JD and generate 'local' download links which can be automatically extracted. While it may not solve the wrong 'log' or 'status' problem, you should be able to move the links using a script, without any issues.
I have other idea. Because extraction log is correct.
So must take correct extraction log and use instead.

So idea is to make manual: 1. Get extraction log
2. Open extraction log
3. And use 'Archive Path:'-value

Is there not API to extract values from log? I think would be useful if simply could make like: getLogValue(logfile).archivepath or getLogValue('Archive Path')

and result would be archive path like: 'c:\user\sherbee\downloads\xyz.7z'

So this could work? And how?
Reply With Quote
  #1474  
Old 26.07.2020, 14:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
... Is there not API to extract values from log? I think would be useful if simply could make like: getLogValue(logfile).archivepath or getLogValue('Archive Path')

and result would be archive path like: 'c:\user\sherbee\downloads\xyz.7z'
...
You can use existing methods to extract matching strings from the log file.

Code:
var match = readFile(getPath(path_to_correct_log_file)).match(/Archive Path\: (.+)/);

if (match) {
    var archivePath = match[1];
    alert(archivePath);
}
Reply With Quote
  #1475  
Old 27.07.2020, 10:26
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
You can use existing methods to extract matching strings from the log file.

Code:
var match = readFile(getPath(path_to_correct_log_file)).match(/Archive Path\: (.+)/);

if (match) {
    var archivePath = match[1];
    alert(archivePath);
}
I try thanks. But you have idea how to get correct path to log file and name? I see no method for it. And not written in any logs to extract? Take last log by date i think not reliable.
Reply With Quote
  #1476  
Old 27.07.2020, 13:18
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
But you have idea how to get correct path to log file and name? I see no method for it. And not written in any logs to extract? Take last log by date i think not reliable.
You don't need to get the correct log file, or even any other data from the 'extraction finished' trigger. You can use any trigger (For e.g. JD started, interval) and loop through the log files of last 'x' hours present in the 'extracting' folder. Parse the content of each file to check if the extraction was 'successful', and if so get a list of 'archive files' and move them. If the log has not already been processed before, the 'archive files' will still be present in the folder and can be moved by the script.
Reply With Quote
  #1477  
Old 27.07.2020, 23:25
Mydgard Mydgard is offline
Fibre Channel User
 
Join Date: Jan 2011
Location: Germany
Posts: 115
Default

Hello fellow programmiers I have no clue about programming nor do i understand all those scripts, but i am searching for a function to change linkgrabber a little bit:

I would like to sometimes shutdown the linkgrabber organisation: Like if i enter 1 link, it will be shown under "verschiedene dateien" (dunno the english name for it), if i than enter 2 more links with part 1 and part 2, they won't be inside the "verschiedene dateien", they get a new folder with the name of these files.

Anyone has an idea how to change that? That ALL Links/Files being in one folder no matter if there are lonely links or links with part 1-x? Ideally with a button for on/off ...

Thx

Mydgard

PS: If Possible must be a ready script as i don't understand this scripting sry :D
Reply With Quote
  #1478  
Old 28.07.2020, 04:55
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,611
Default

@Mydgard
verschiedene dateien = various files
in english the title is just various, you can disable various in advanced settings
settings > advanced settings > LinkgrabberSettings.variouspackageenabled
you can also edit a threshold which links are no longer in various LinkgrabberSettings.variouspackagelimit
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1479  
Old 28.07.2020, 08:02
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
You don't need to get the correct log file, or even any other data from the 'extraction finished' trigger. You can use any trigger (For e.g. JD started, interval) and loop through the log files of last 'x' hours present in the 'extracting' folder. Parse the content of each file to check if the extraction was 'successful', and if so get a list of 'archive files' and move them. If the log has not already been processed before, the 'archive files' will still be present in the folder and can be moved by the script.
But that not what I need.
I need:
1. Open archive
2. Extract archive
3. Move archive
4. Open next archive

Must move archive after extraction immediately.
Reply With Quote
  #1480  
Old 28.07.2020, 09:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sherbee View Post
But that not what I need.
I need:
1. Open archive
2. Extract archive
3. Move archive
4. Open next archive

Must move archive after extraction immediately.
It effectively does the same thing. The files will be moved as soon as the log file is available in the 'extracting' folder and queried. How fast you want it to be processed will depend on the the trigger you use.
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 19:36.
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.