|
#1
|
|||
|
|||
Event Script - Move Completed Downloads.
I don't plan on using the RAR Extension and would rather unrar the files myself. I had a look at the event scripter as an option of moving downloaded files once they were complete but the scripting language I'm unfamiliar with. Could someone whip up a quick script that moves files from the download directory to another directory if file is complete?
Just a script that moves ANY file type, including archives. As I won't be extracting them using JD2. I should be able to adjust the script to accommodate for the proper directories. If it helps, I'm running headless JD2 on Linux Ubuntu server, so directory structure is ~/ or /home/ (if absolute). I appreciate anyone willing to assist. In the meantime, I will continue reading up on the language used and see if I can't figure things out. Last edited by dbrown1986; 20.10.2020 at 09:26. |
#2
|
|||
|
|||
Quote:
Code:
// Move downloaded files to user-specified folder // Trigger: A Download Stopped if (link.finished) { var destinationFolder = "/home/"; getPath(link.downloadPath).moveTo(destinationFolder); } |
#3
|
|||
|
|||
Quote:
eg. move files which are less than 999 MB. |
#4
|
||||
|
||||
@mgpai: thanks for your fast help
@dbrown1986: Just out of interest, why don't you want to use the out-of-the-box extraction support?
__________________
JD-Dev & Server-Admin |
#5
|
|||
|
|||
Quote:
Just a few issues I have run into on the headless install over the remote server. Also being that I'm syncing it to a team drive over rClone, sometimes the rar.part files don't get properly renamed when trying to download directly to the rClone mount or file conflict issues when trying to extract to the sync folder. Limitations of the OS or rClone, I'm sure, but I think it better to simply leave it in RAR format as well, so that they're easier to download via GDrive as well as keep googles built-in AV from complaining about any false-positives. I'm smart enough to scan files on my end with my own A/V. |
#6
|
|||
|
|||
Quote:
Code:
// Move downloaded files to user-specified folder and remove the link from download list // Trigger: A Download Stopped if (link.finished) { var destinationFolder = "/home/"; getPath(link.downloadPath).moveTo(destinationFolder); link.remove(); } |
#7
|
||||
|
||||
@dbrown1986: Thanks for the feedback!
__________________
JD-Dev & Server-Admin |
#8
|
|||
|
|||
Well, already ran into an issue. The script removes finished links, but does nothing else. The web gui would not allow me to import, so I used the Android app to do so. That resulted in the following:
Code:
[ { "eventTrigger" : "ON_DOWNLOAD_CONTROLLER_STOPPED", "enabled" : true, "name" : "Move Completed Downloads", "script" : "if (link.finished) {var destinationFolder = \"/home/seedit4me/drive/debrid/\"; getPath(link.downloadPath).moveTo(destinationFolder); link.remove(); }", "eventTriggerSettings" : { "isSynchronous" : false }, "id" : 1603194963402 } ] |
#9
|
||||
|
||||
@dbrown1986: The webUI you have to correct format the script! You cannot directly copy/paste in there. The script of mgpai is for script editor. Best is to use JDownloader with gui and edit/test your scripts there and later copy/paste them via Settings->Advanced Settings->EventScripter.scripts
__________________
JD-Dev & Server-Admin |
#10
|
|||
|
|||
Quote:
Last edited by dbrown1986; 20.10.2020 at 15:45. |
#11
|
||||
|
||||
Can you copy paste the exact input to pastebin and give me link, so I can check?
__________________
JD-Dev & Server-Admin |
#12
|
|||
|
|||
Input Script:
**External links are only visible to Support Staff****External links are only visible to Support Staff** Produces Output Script in JSON: **External links are only visible to Support Staff****External links are only visible to Support Staff** This is using JD2 GUI on Windows. |
#13
|
||||
|
||||
Is all correct. What do you think is wrong?
__________________
JD-Dev & Server-Admin |
#14
|
|||
|
|||
I got it to work on the GUI and headless now. Yay!
I didn't think about it, but if I wanted to have the downloads that are moved; be in there own subfolder, would I just add <jd:packagename> to the end of {var destinationFolder = "/home/" ? |
#15
|
|||
|
|||
Quote:
Code:
var destinationFolder = getPath("/home/seedit4me/drive/debrid/" + link.package.name); |
#16
|
||||
|
||||
You can verify via json parser and json decoder, eg
jsonformatter.org/json-pretty-print and **External links are only visible to Support Staff****External links are only visible to Support Staff**
__________________
JD-Dev & Server-Admin |
#17
|
|||
|
|||
Code:
if (link.finished) {var destinationFolder = getPath("/home/seedit4me/drive/debrid/" + link.package.name); getPath(link.downloadPath).moveTo(destinationFolder); link.remove(); } Could you correct it for me? Not sure where that line should go. Last edited by dbrown1986; 23.10.2020 at 04:40. |
#18
|
|||
|
|||
Quote characters must be escaped:
Code:
var destinationFolder = getPath(\"/home/seedit4me/drive/debrid/\" + link.package.name); Better to install it in GUI and then copy the JSON value from advanced setings and paste it in the headless install via corresponding WebUI advanced settings. Code:
Settings > Advanced Settings > EventScripter.scripts Alternatively, after you install the script in GUI, you can copy the following file from GUI to headless: Code:
<JDdownloader Folder>\cfg\org.jdownloader.extensions.eventscripter.EventScripterExtension.scripts.json |
#19
|
|||
|
|||
Quote:
I was able to determine that this was because of something in the way the rClone mount is managed. The move is failing, so the script moves on to the next instruction, which is to clear the downloaded file from the download list. As a test, I manually moved it in WinSCP and got Error 4; so I copied it instead and the copy worked without any flaws. Can you make one more adjustment to the script for me? Can you take what you've done so far, including the sub-folder by package adjustment, and modify it to copy instead of move? I will use the COPY w/ sub-folder script on the headless, but I will have a fallback machine as well for a MOVE w/ sub-folder script. would replacing moveTo with copyTo do the trick? @mgpai @Jiaz So immensely thankful! If you have a "Buy me a coffee" or similar thing, send it to me in a private message. I'll throw you both a couple bucks for all the help you've provided. EDIT: Somehow I broke it. JSON Pretty says the script checks out but now that I modified the var destinationFolder it won't move or copy the file at all on the windows gui or on the headless linux box. This is how I modified the script: Code:
[ { "eventTrigger": "ON_DOWNLOAD_CONTROLLER_STOPPED", "enabled": true, "name": "Move Completed Downloads", "script": "if (link.finished) var destinationFolder = getPath(\"/home/seedit4me/drive/debrid/\" + link.package.name); getPath(link.downloadPath).moveTo(destinationFolder); link.remove(); }", "eventTriggerSettings": { "isSynchronous": false }, "id": 1603260255137 } ] Last edited by dbrown1986; 23.10.2020 at 17:50. |
#20
|
||||
|
||||
Quote:
If you want to buy a coffee for mgpai, you will have to contact him separately Thanks again mgpai! -psp-
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
Thread Tools | |
Display Modes | |
|
|