docker-jdownloader-2 icon indicating copy to clipboard operation
docker-jdownloader-2 copied to clipboard

Event Scripter capabilities

Open benfishbus opened this issue 6 years ago • 15 comments

I want to add a script to send a Prowl notification when a package finishes downloading, but doing that - or just about anything useful - in the JDownloader Event Scripter plugin requires calling system binaries like 'curl' which aren't available in the container. I'm sure this is a basic docker question, but is there a way for me to lightly tweak your container to include additional packages?

benfishbus avatar Dec 28 '17 05:12 benfishbus

You can add curl package to a running container by executing docker exec <container name> add-pkg curl.

However, I guess that useful package can be added to the official image if needed.

Also, did you check if what you want to achieve can be done via the Event Scripter API?

jlesage avatar Dec 30 '17 18:12 jlesage

Adding the curl package this way worked - thank you. I'm guessing that this change will be lost when the container is restarted. Is there a way to apply it to my copy of the image, so that you don't have to?

I looked into performing this notification directly in Event Scripter, but didn't see any relevant functions in the jdownloader documentation. I don't know much about regular javascript, but the method I read about for doing HTTP POST (XMLHttpRequest) is not available in Event Scripter.

benfishbus avatar Jan 03 '18 06:01 benfishbus

The change would not be lost if container is stopped. Only when it is removed/re-created.

I found those links which have scripts doing http get/post using the event scripter API. I guess you should be able to perform your notification with something similar:

https://support.jdownloader.org/Knowledgebase/Article/View/58/0/ifttt-connect-web-services-with-your-jdownloader https://board.jdownloader.org/showpost.php?p=384496&postcount=36

jlesage avatar Jan 03 '18 18:01 jlesage

Hi - I just wanted to check and see if you've put more thought into adding curl to the official image of Jdownloader2. Running into basically the same situation as OP - did a manual 'apk add curl' so that for now the script can run but I'd like it to not have to be fiddled with every update.

cbackas avatar Sep 26 '18 14:09 cbackas

One solution that won't be affected by image updates is to create a small shell script in /config that will do the curl call. The event scripter would call the shell script instead.

The script would be something like this:

#!/usr/bin/sh
[ -n "$(which curl)" ] || add-pkg curl
curl [...]

jlesage avatar Sep 26 '18 15:09 jlesage

Hmm... We had tried to include the stuff to run and add the curl package in our shell script but it wasn't working... I'll give it another shot later and let you know if I have any problems

cbackas avatar Sep 26 '18 16:09 cbackas

Ah yes you are right. The user used to run JDownloader cannot install packages...

jlesage avatar Sep 26 '18 17:09 jlesage

So does that mean we can get the curl package added to the docker image? :)

cbackas avatar Sep 26 '18 18:09 cbackas

I already had a snippet saved with all the commands to pull, nuke and rebuild each of my containers and just added the curl install to that. Not elegant but works 🙂 On Wed, Sep 26, 2018 at 1:52 PM Jocelyn Le Sage [email protected] wrote:

Ah yes you are right. The user used to run JDownloader cannot install packages...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlesage/docker-jdownloader-2/issues/8#issuecomment-424809971, or mute the thread https://github.com/notifications/unsubscribe-auth/ANYfYQeqMBt3tBiz8KTodrZqbXpKLDQQks5ue77VgaJpZM4ROB1P .

benfishbus avatar Sep 26 '18 18:09 benfishbus

So does that mean we can get the curl package added to the docker image? :)

Maybe not adding the package directly, but I guess I need to provide an easy way to install it, either via an environment variable or by allowing a user-provided custom init script.

jlesage avatar Sep 26 '18 19:09 jlesage

Ooh a user-provided customer init script sounds great

cbackas avatar Sep 26 '18 19:09 cbackas

Hi! @jlesage, any progress on this idea? Would love to get this environment variable ability.

Thanks

cbackas avatar Nov 28 '18 15:11 cbackas

This feature will be available with the new baseimage I'm working on. I don't have an ETA but I can say that a good amount of work is already done on it.

jlesage avatar Dec 04 '18 19:12 jlesage

One solution that won't be affected by image updates is to create a small shell script in /config that will do the curl call. The event scripter would call the shell script instead.

The script would be something like this:

#!/usr/bin/sh
[ -n "$(which curl)" ] || add-pkg curl
curl [...]

Currently I'm trying to start a bash script via the Event Scripter. But all the time I get the following error "no such file or directory".

The script is located in the config folder and has the permissions 755.

When I select File > Load a Link Container in JDownloader I also see the file in the config folder.

What's the problem? Could someone already start a bash script via the Event Scripter with the Docker version? Thanks.

Mnk3y avatar Apr 20 '20 11:04 Mnk3y

Note that bash is not part of the image. So make sure you script begins with #!/bin/sh instead of #!/bin/bash.

jlesage avatar Apr 24 '20 02:04 jlesage

I know its an old bug report, but i have the same problem as @Mnk3y, whenever i try to test run, it get the error "no such file or directory", when i directly change into the container (docker exec -it jdownloader sh) i can see the file and run it, so it should be there, but the event scripter can't find it for some reason. I also seethe file in jdownloader via load a link container like Mnk3y. Did you manage to start your script?

Slomo17 avatar Nov 15 '22 21:11 Slomo17

What are the permissions on the file ?

jlesage avatar Nov 15 '22 23:11 jlesage

I change it to 777, but that didn't do the trick. With a jdownloader running locally without docker the script works

Slomo17 avatar Nov 16 '22 10:11 Slomo17

Can you provide more details so I can reproduce on my side ? Maybe share your JD script ?

I did a quick test and it works fine for me.

jlesage avatar Nov 16 '22 14:11 jlesage

My script looks like this


#!/bin/sh

#call filebot
curl "http://filebot:5452/task?id=6"

# clean clutter
find output/Finished/ -iname "*.nfo" -type f -delete
find output/Finished/ -iname "sample" -type d -exec rm -rf {} \;
find output/Finished/ -empty -type d -delete

# Scan to Kodi Database
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://[user]:[password]@192.168.178.21:8080/jsonrpc

exit 0

Slomo17 avatar Nov 17 '22 17:11 Slomo17

And how this script is invoked in the JDownloader event scripter ?

jlesage avatar Nov 17 '22 17:11 jlesage

var script  = '/Downloads/filebot.sh'
callSync(script)

maybe there lies the problem, this works outside of docker

Slomo17 avatar Nov 17 '22 17:11 Slomo17

What docker exec <container name> ls -l /Downloads/filebot.sh shows ?

jlesage avatar Nov 17 '22 19:11 jlesage

I don't know what i did wrong, but now it works. I changed the voulme mapping in docker-compose many times while trying to solve the problem, maybe something got mixed up there. Thank you very much for your help.

Slomo17 avatar Nov 17 '22 21:11 Slomo17

Ok great!

I think we can now close this issue.

jlesage avatar Nov 18 '22 19:11 jlesage