JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #2301  
Old 12.06.2022, 11:51
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Jiaz View Post
good catch but I still wonder why the null pointer happens on
getDownloadFolder and not on getPackage then.
Just checked, 'package finshed' trigger also returns a link object, which returns the the download folder correctly, if "Remove finished downloads" is not enabled. If however the "Remove finished downloads" is enabled, instead of the link object (instance) it will return only a hashmap where package is set to null.
Reply With Quote
  #2302  
Old 12.06.2022, 12:10
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

@mgpai: added missing link to test properties for this event.
when you have *remove finished downloads*, then the reference to its parent/Filepackage is removed and thus package is null. but the package reference should still work fine
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2303  
Old 12.06.2022, 17:41
excidius excidius is offline
Vacuum Cleaner
 
Join Date: Apr 2011
Posts: 17
Default

Ok, Yes.. I did have it set to Autoremove Downloads on complete..
It works now, after turning that off! thank you guys for the help.. :-)
Reply With Quote
  #2304  
Old 13.06.2022, 07:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Jiaz View Post
@mgpai: synchronous script with dummy script ... I will add new DownloadLinkSandbox.isAborting() method for this
Synchronous execution cannot be enabled (gets unchecked on save).
Reply With Quote
  #2305  
Old 13.06.2022, 08:06
Student im ersten Jahr Student im ersten Jahr is offline
Black Hole
 
Join Date: Nov 2020
Posts: 252
Default

@mgpai - Can you please provide a script to save direct links to a text file?

https://board.jdownloader.org/showpo...postcount=3250
Reply With Quote
  #2306  
Old 13.06.2022, 08:57
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Student im ersten Jahr View Post
@mgpai - Can you please provide a script to save direct links to a text file?
Code:
/*
    Save direct links to text
    Trigger: A Download stopped
*/

if (link.downloadHost == "vk.com") {
    var directLink = link.getProperty("picturedirectlink") || link.getProperty("directurls_fallback");

    try {
        directLink && writeFile(link.downloadPath + ".txt", directLink, false);
    } catch (e) {};
}

@Jiaz: One example where mere mortals who wish to offer support/help need access to obfuscated content.
Reply With Quote
  #2307  
Old 13.06.2022, 11:23
Student im ersten Jahr Student im ersten Jahr is offline
Black Hole
 
Join Date: Nov 2020
Posts: 252
Default

1. I have installed "Event Scripter"
2. I have added this script.
3. Enabled.
But is there anything more that should be done?
By default I have "Trigger": None
And where are the links saved on the disk?

Code:
Spoiler:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "link" is not defined. (#6) 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(:6) 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: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:320) at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:180) at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:160)
Reply With Quote
  #2308  
Old 13.06.2022, 11:38
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Student im ersten Jahr View Post
By default I have "Trigger": None
Set trigger as specified in the script:
Code:
Trigger: A Download stopped

Quote:
Originally Posted by Student im ersten Jahr View Post
And where are the links saved on the disk?
Same download location, Same name. Extension 'txt'.
Reply With Quote
  #2309  
Old 13.06.2022, 11:39
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

Quote:
Originally Posted by Student im ersten Jahr View Post
By default I have "Trigger": None
see the script info
Quote:
Originally Posted by mgpai View Post
Code:
/*
    Trigger: A Download stopped
*/
Quote:
Originally Posted by Student im ersten Jahr View Post
By default I have "Trigger": None
And where are the links saved on the disk?
it's stored as filePath.txt
Quote:
link.downloadPath + ".txt"
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2310  
Old 13.06.2022, 18:22
Student im ersten Jahr Student im ersten Jahr is offline
Black Hole
 
Join Date: Nov 2020
Posts: 252
Default

mgpai & Jiaz Now it's Ok! Thanks a lot!
Reply With Quote
  #2311  
Old 15.06.2022, 12:19
m_speed m_speed is offline
Modem User
 
Join Date: Jun 2022
Posts: 2
Default File extraction in order

Requesting a script that waits until file extraction is done before starting with the next download. Then auto renames the extracted file to the rar's name.
Reply With Quote
  #2312  
Old 15.06.2022, 12:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

Quote:
Originally Posted by m_speed View Post
Requesting a script that waits until file extraction is done before starting with the next download. Then auto renames the extracted file to the rar's name.
@mgpai: you can active wait in while(isextracting)sleep(1) or something like that
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2313  
Old 15.06.2022, 12:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Jiaz View Post
@mgpai: you can active wait in while(isextracting)sleep(1) or something like that
Is there an 'isExtracting' call/method? Have created a script which checks extraction queue. Guess that should do the job. But, THIS bug needs to be fixed first for the script to work.

Quote:
Originally Posted by m_speed View Post
Requesting a script that waits until file extraction is done before starting with the next download.
Code:
/*
    Wait till extraction is finished
    Trigger : A Download Started
    IMPORTANT: Enable 'Synhronous Execution' checkbox in the top panel
*/

while(isExtracting()){
    sleep(1000);
}

function isExtracting() {
    return callAPI("extraction", "getQueue").length > 0;
}

A bug currently prevents the 'sync execution' setting to be saved. Please wait for the bug fix before starting to use the script.

Quote:
Originally Posted by m_speed View Post
Then auto renames the extracted file to the rar's name.
You can use packgizer for this. It has an option to rename files after extraction.
Reply With Quote
  #2314  
Old 15.06.2022, 13:09
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

Quote:
Originally Posted by mgpai View Post
You can use packgizer for this. It has an option to rename files after extraction.
user wants the archive filename to be used, so I guess script would be much easier
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2315  
Old 15.06.2022, 13:10
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

Quote:
Originally Posted by mgpai View Post
A bug currently prevents the 'sync execution' setting to be saved. Please wait for the bug fix before starting to use the script.
Will be fixed with next core update
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2316  
Old 15.06.2022, 13:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Jiaz View Post
user wants the archive filename to be used, so I guess script would be much easier
I think there are some scripts in this thread which could that. But, end-users may find it easier to customize it in packagizer than tweak the script. I have recommended it in the past to several users, and I guess should still work fine.

For example, packagename is usually derived from archive name. So can use:
Code:
Then do > rename to : <jd:packagename>.<jd:orgfiletype>

(Tested just now. Working fine)

Guess a packagizer property for archive name will be useful in cases like this.

<jd:archivename> ?
Reply With Quote
  #2317  
Old 15.06.2022, 14:09
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

Quote:
Originally Posted by mgpai View Post
guess a packagizer property for archive name will be useful in cases like this.
<jd:archivename> ?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2318  
Old 15.06.2022, 14:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Jiaz View Post
user wants the archive filename to be used, so I guess script would be much easier
Code:
/*
    Rename extracted files
    Trigge: Archvie extraction finished
*/

var name = archive.name;

archive.extractedFilePaths.forEach(function(filePath) {
    filePath.renameName(name + "." + filePath.extension);
})
Reply With Quote
  #2319  
Old 15.06.2022, 16:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by StefanM View Post
(Random) delay while downloading
Quote:
Originally Posted by Jiaz View Post
@mgpai: synchronous script
Code:
/*
    Random delay before download
    Trigger : A Download Started
    IMPORTANT : Enable "Synchronous execution" checkbox in the top panel
*/

var seconds = Math.floor(Math.random() * 5) + 1 // 1 to 5 seconds

while (seconds && !link.aborting) {
    sleep(seconds * 1000);
    seconds--;
}
Reply With Quote
  #2320  
Old 16.06.2022, 11:09
theskyishigh theskyishigh is offline
Baby Loader
 
Join Date: Oct 2015
Posts: 7
Default

Script to Clean Up Download Tab

Hi. I need a script to clean up my Download tab. Basically, remove all finished packages/files that have been deleted/moved. Such a script would need to do the following.

1. Go through all the packages that have finished downloading.
2. Check if the downloaded files exist on the disk.
3. If the downloaded files do not exist on the disk, then remove them from the download tab.
4. If the package folder does not exist on the disk, then remove it from the download tab.

Is there already such a script? @Jiaz suggested that @mgpai might be able to help?

Thanks in advance for any help anyone may provide.
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 03:14.
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.