JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #2021  
Old 05.11.2021, 20:14
tb21 tb21 is offline
Junior Loader
 
Join Date: Oct 2021
Posts: 12
Default

Ok, thank you, I think that could answer some of my questions, I will try some more. o) So the newer methods return null/object and create parents, is there any drawback using the new methods or any reason to still use the old ones?

EDIT: Found the source for some of the file/folder methods here, seems helpful to explore the differences:
github.com/mirror/jdownloader/blob/master/src/org/jdownloader/extensions/eventscripter/sandboxobjects/FilePathSandbox.java

Last edited by tb21; 05.11.2021 at 21:04.
Reply With Quote
  #2022  
Old 06.11.2021, 06:24
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by tb21 View Post
I mostly tried folders which contain subfolders (iirc)..
I am guessing you are trying to move the entire folder using a single 'moveTo' call, which is not possible using this method.

You will have to use folder.getChildren() to recursively access/move each object in the folder. Using this method I have been able move entire folders with folder structure intact, even across different drives. It will however leave empty folders behind in the source location, which can also be removed using the same script.

Another option (perhaps easier one) is to use external programs (OS or 3rd party) in eventscripter to move it.
Reply With Quote
  #2023  
Old 06.11.2021, 11:56
tb21 tb21 is offline
Junior Loader
 
Join Date: Oct 2021
Posts: 12
Default

Yes, thank you for confirming, after analyzing the linked source file it is clear..
There is no recursive copy/move support in any of these methods. I did the getChildren() thing and did some new methods to make this work, I think they turned out nicely, will provide them here when final testing is done.

Using an external tool is an option, yes, but that would tie the script to specific OS variants unless you branch depending on OS (I saw you have methods to do that). There's another downside with external tools though, in case things go wrong, it's much harder to get down to the problem (needs analyzing of std-err output or something?!).

I am quite fine with the built in methods, the only thing I miss is being able to re-set the "modified" and "created" timestamps for copied/moved files. Losing timestamps is a severe disadvantage here. There is FilePath.getModifiedDate() already..

Who must I pay to add setModifiedDate(), getCreatedDate(), setCreatedDate()?
To get fully working OS independent, recursive copy and move without losing timestamps? o)
Reply With Quote
  #2024  
Old 06.11.2021, 20:57
mrjjones mrjjones is offline
Vacuum Cleaner
 
Join Date: Nov 2021
Posts: 17
Post callSync with parameters

Does anyone know how to pass along parameters with callSync? I'm trying to send notifications with "notify-send" in ubuntu like:

Code:
callSync("notify-send","some text");

and that works fine, but if I want to add an icon, like with "-i battery" to the notify-send command, it does nothing. I tried many combinations with no luck. Thanks for any advice.
Reply With Quote
  #2025  
Old 07.11.2021, 03:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by mrjjones View Post
... I want to add an icon, like with "-i battery" ...
Code:
callSync("notify-send", "some text", "-i", "battery");
Reply With Quote
  #2026  
Old 07.11.2021, 11:16
Gbyte Gbyte is offline
I will play nice!
 
Join Date: Nov 2021
Posts: 4
Default

Quote:
Originally Posted by Jiaz View Post
@Gbyte:
Extraction.customextractionpathenabled
and
Extraction.customextractionpath
Now i get this error or is the mistake on my end?

I use this script in the event scripter:

Code:
var script = '/REDACTED/jdownloader-postprocess.sh'

var package = archive.getDownloadLinks() ? archive.getDownloadLinks()[0].getPackage() : null
var links = package ? package.getDownloadLinks() : []

function isReallyFinished() {
    for (var i = 0; i < links.length; i++) {
        if (links[i].getArchive() != null && links[i].getExtractionStatus() != "SUCCESSFUL" || !package.isFinished()) {
            return false
        }
    }
    return true
}

if (package && isReallyFinished()) {
    var command = [script, Extraction.customextractionpath(), package.getName(), package.getComment() ? package.getComment() : 'N/A', 'ARCHIVE_EXTRACTED']
    log(command)
    log(callSync(command))
}
Attached Images
File Type: png 88567576.png (233.1 KB, 1 views)
Reply With Quote
  #2027  
Old 07.11.2021, 14:08
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Gbyte View Post
Now i get this error or is the mistake on my end?
Since I cannot access your screenshot, I cannot also know the exact error you are getting. But, the following method used in the script is invalid:
Code:
Extraction.customextractionpath()

Try replacing it with:
Code:
archive.getExtractToFolder();
Reply With Quote
  #2028  
Old 07.11.2021, 21:10
Gbyte Gbyte is offline
I will play nice!
 
Join Date: Nov 2021
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Since I cannot access your screenshot, I cannot also know the exact error you are getting. But, the following method used in the script is invalid:
Code:
Extraction.customextractionpath()

Try replacing it with:
Code:
archive.getExtractToFolder();
Thank you a lot. Now it works :D

Note for the mod: When will my account be unlocked for "more" freely usage?
Reply With Quote
  #2029  
Old 07.11.2021, 21:58
mrjjones mrjjones is offline
Vacuum Cleaner
 
Join Date: Nov 2021
Posts: 17
Default

Quote:
Originally Posted by mgpai View Post
Code:
callSync("notify-send", "some text", "-i", "battery");
@mgpai thank you very much. It seems so obvious now to split the -i and battery which is something I didn't try. Ugh.
Reply With Quote
  #2030  
Old 07.11.2021, 23:29
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,599
Default

@mrjjones
yes for some reason you cant have any spaces between switches and/or user defined section, must be all separated.

@Gbyte
unfortunately it has nothing todo with your account type, every user can post images/urls/etc but can not be viewed by anyone but moderators/admins. This is due to security/privacy concerns.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #2031  
Old 08.11.2021, 01:16
JDL1059 JDL1059 is offline
Junior Loader
 
Join Date: Oct 2021
Posts: 10
Default

Quote:
Originally Posted by mgpai View Post
Code:
/*
    Interval > Add urls
    Trigger : Interval (Recommended 3600000 or more)
*/

var file = "Downloads/.torrent files/JDL Sync.txt";// <- Set path to text file

try {
    var links = readFile(getPath(file));

    callAPI("linkgrabberv2", "addLinks", {
        links: links
    })
} catch (e) {};
thank you. What are the steps to enable this script? I went to "Event Scripter", clicked "add", set the "Trigger" to "Interval" and then within the Edit Script button added the code above pointing to my text file which has 4 different megaupload links. I set the call interval to 259200000 i.e. 3 days. Synchronous execution of script checkbox is ticked. I hit test compile and it says successful, but when i hit test run, nothing happens. I tried changing the interval to 1000ms and nothing happened either. Any idea? **External links are only visible to Support Staff**... of my JDL install.
Reply With Quote
  #2032  
Old 08.11.2021, 04:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by JDL1059 View Post
.... I hit test compile and it says successful, but when i hit test run, nothing happens ...
The url in your post is obfuscated. Most likely the file path is invalid and hence the script is unable to find the file. Use the following script for testing, it will display the relevant error message.

Code:
/*
    Interval > Add urls
    Trigger : Interval (Recommended 3600000 or more)
*/

var file = "Downloads/.torrent files/JDL Sync.txt"; // <- Set path to text file

try {
    var links = readFile(getPath(file));

    callAPI("linkgrabberv2", "addLinks", {
        links: links
    })
} catch (e) {
    alert(e.message);
};

Pleas note, JD should be running for a longer period than the interval specified for it to be triggered.
Reply With Quote
  #2033  
Old 08.11.2021, 23:17
Crank436 Crank436 is offline
Ultra Loader
 
Join Date: Aug 2016
Posts: 45
Default

Hey!
Maybe you can help me, im new to this scripting stuff.
I'm trying to write a script, to always have a specific amount of time between two reconnects.
I have one script "after each reconnect" which should safe the current time.
Another script "before each reconnect" which checks, if the time since the last reconnect is < x, and if not it waits until its < x (e.g. 90s).

Now my problem: I cant access the variable from the first script in the second one. How can I make this global? I read that its global in Javascript, if its not inside a function. It isnt, its just
now = new Date()

Sorry, I'm really a total new to this...
Reply With Quote
  #2034  
Old 08.11.2021, 23:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Crank436 View Post
I cant access the variable from the first script in the second one. How can I make this global?
You can find details on the method in the built-in help in script editor.
Code:
/*
    After a reconnect
*/
    
setProperty("lastReconnectTime", Date.now(), true);
Code:
/*
    Before a reconnect
*/

var lastReconnectTime = getProperty("lastReconnectTime", true);
Reply With Quote
  #2035  
Old 09.11.2021, 15:34
stakelabel stakelabel is offline
Baby Loader
 
Join Date: Nov 2021
Posts: 6
Default Site Specific Script

hi, Thanks for the great software!

(1)Pass through the link grabber.
There is always a URL to download.

I tried, but dont work..
--
var host = "myhost.com";
var myString = myDownloadLink.getDownloadHost();
startDownloads();
--

(2)Unzip after downloading only the specified URL
Now everything is unzip after download.

I found a script that does batch processing after unzipping. tnx:)
callAsync(function(){},"cmd","/c","c:/myFolder/myBatch.bat");
Reply With Quote
  #2036  
Old 09.11.2021, 15:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by stakelabel View Post
I tried, but dont work..
Are both scripts not working? Can you explain in detail what do you want the script to do or post your script here?
Reply With Quote
  #2037  
Old 09.11.2021, 16:28
stakelabel stakelabel is offline
Baby Loader
 
Join Date: Nov 2021
Posts: 6
Default

Quote:
Originally Posted by mgpai View Post
Are both scripts not working? Can you explain in detail what do you want the script to do or post your script here?
sorry,, I am looking for two scripts.
Reply With Quote
  #2038  
Old 09.11.2021, 16:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by stakelabel View Post
sorry,, I am looking for two scripts.
I will need more info. Contact me in IRC:
Code:
kiwiirc.com/nextclient/irc.libera.chat/#jdownloader
Reply With Quote
  #2039  
Old 09.11.2021, 18:26
Crank436 Crank436 is offline
Ultra Loader
 
Join Date: Aug 2016
Posts: 45
Default

Thank you for your help Mr Script Master!
Reply With Quote
  #2040  
Old 12.11.2021, 17:59
JDL1059 JDL1059 is offline
Junior Loader
 
Join Date: Oct 2021
Posts: 10
Default

Quote:
Originally Posted by mgpai View Post
The url in your post is obfuscated. Most likely the file path is invalid and hence the script is unable to find the file. Use the following script for testing, it will display the relevant error message.

Code:
/*
    Interval > Add urls
    Trigger : Interval (Recommended 3600000 or more)
*/

var file = "Downloads/.torrent files/JDL Sync.txt"; // <- Set path to text file

try {
    var links = readFile(getPath(file));

    callAPI("linkgrabberv2", "addLinks", {
        links: links
    })
} catch (e) {
    alert(e.message);
};

Pleas note, JD should be running for a longer period than the interval specified for it to be triggered.
ah thank you. I got this working perfectly. Amazing!!!
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 08:16.
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.