How to run .bat script on torrent completion?

Specific support for Deluge on Microsoft Windows OS
gfdgdfhwetf
New User
New User
Posts: 4
Joined: Tue Dec 31, 2019 11:59 am

How to run .bat script on torrent completion?

Post by gfdgdfhwetf »

I'm coming Qbittorrent on Windows where I execute the following command to run a .bat script to unpack my torrent:

C:\Users\Me\Documents\others\script\winrarExtractor.bat "%F\*".rar "%F"

Which works fine.

Now I have installed Deluge and wanted to do the same thing, unzip files when they are done. I have Deluge 1.3.15.

First I tried two "extractor" plugins, Extractor and LCExtractor but none of these seems to work at all. Then I installed a plugin called Execute which is supposed to allow me to execute a script on torrent completion. I used the same command that I used in Qbittorrent but it doesn't work either. How can I change my command above to make this work?
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to run .bat script on torrent completion?

Post by mhertz »

The Execute plugin is supplied together with deluge(included as part of 10 default plugins), so no need to install it unless you merely meant enabling it. There's an enhanced version of that also available for install, by third-party, but not really needed for your use-case.

I'm not at home now so cannot test the following, but a directly translated line from qBittorrent to deluge would be:

Code: Select all

 
C:\Users\Me\Documents\others\script\winrarExtractor.bat "$3\$2"\*.rar "$3\$2"

(I did a quick search for an old forum post of mine here, where I posted some execute plugin related code, and took the syntax from there. I remember originally I had to play around with how the double-quoting should be done for files/dirs with space, as only some variations worked, and the above way worked on linux atleast.)

Your original line, and my translation only works for folders with dirs in them and need modification if the torrent is a rar without folder, but I don't believe normally rar releases come like that anyway.
gfdgdfhwetf
New User
New User
Posts: 4
Joined: Tue Dec 31, 2019 11:59 am

Re: How to run .bat script on torrent completion?

Post by gfdgdfhwetf »

mhertz wrote:The Execute plugin is supplied together with deluge(included as part of 10 default plugins), so no need to install it unless you merely meant enabling it. There's an enhanced version of that also available for install, by third-party, but not really needed for your use-case.

I'm not at home now so cannot test the following, but a directly translated line from qBittorrent to deluge would be:

Code: Select all

 
C:\Users\Me\Documents\others\script\winrarExtractor.bat "$3\$2"\*.rar "$3\$2"

(I did a quick search for an old forum post of mine here, where I posted some execute plugin related code, and took the syntax from there. I remember originally I had to play around with how the double-quoting should be done for files/dirs with space, as only some variations worked, and the above way worked on linux atleast.)

Your original line, and my translation only works for folders with dirs in them and need modification if the torrent is a rar without folder, but I don't believe normally rar releases come like that anyway.

Thanks! I tried running your command but nothing seem to happen. Is there any way to read logs/debug to know what the error is?
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to run .bat script on torrent completion?

Post by mhertz »

I'm sorry, try this instead:

Code: Select all

C:\Users\Me\Documents\others\script\winrarExtractor.bat "%3\%2\*.rar" "%3\%2"
Else try this to get a log(execute.log in Documents folder) of what command exactly is (trying-to) run:

Code: Select all

echo C:\Users\Me\Documents\others\script\winrarExtractor.bat "%3\%2\*.rar" "%3\%2" >> "%userprofile%\documents\execute.log"
gfdgdfhwetf
New User
New User
Posts: 4
Joined: Tue Dec 31, 2019 11:59 am

Re: How to run .bat script on torrent completion?

Post by gfdgdfhwetf »

Odd, this made Deluge crash and now it won't start.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to run .bat script on torrent completion?

Post by mhertz »

Sorry, I tried, but cannot even get the execute plugin to work on windows, and read several have same issue, I tried 10 times with small variations, and debug logging doesn't help either, and atleast for now have no more time, so if the commands I gave you make deluge crash, then delete execute.conf from deluge config dir and start deluge again. (delete 'C:\Users\me\appdata\Roaming\deluge\execute.conf')

(That last command I gave you for loggin works by itself, I checked, and I don't understand how make deluge crash, but nonetheless).

I use execute plugin fine on linux, but something is different here unfortunetly.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to run .bat script on torrent completion?

Post by mhertz »

I have setup the execute plugin to run the test logging batch-file posted above, then without further touching anything, then running a download in deluge 1.3.15 works with test batch-file, but when running a download afterwards in deluge 2.0.3 it doesn't, and no batch-file ever run and nothing in log about it.

I don't know the script you're trying to run originally(winrarextractor.bat), and also I don't wanna test with downloading rar archives because all I can find are illegal, and i'm not going to be setting up VPN in my windows VM also, sorry.

However, if you're using deluge 1.3.15 as you stated, then it should work, and I quickly looked up commands used for this on winrar's CLI version, and I think the following should work:

Code: Select all

"C:\Program Files\WinRAR\Rar.exe" -df x -y "%3\%2\*.rar"
If having winrar installed as not x64 but x32 then:

Code: Select all

"C:\Program Files (x86)\WinRAR\Rar.exe" -df x -y "%3\%2\*.rar"
(I probably could have used simply %programfiles%, but during testing I used full paths just to make sure everything was working and rule out any possible "conflict" or issue arrising).

That command-line should unpack rars, if found, in same folder where found, and delete source files afterwards.

Btw, back when I used windows many years ago, I quickly switched to 7-ZIp instead of winrar, as free(also open-source which doesn't hurt), is lighter, can compress better(with it's own 7z format, buy also simply zip archives gets roughly 10% better compression than using e.g. winzip when both set to max compression for zips) and unpack more formats, including rars, so if wanting to explore that option instead, then e.g.:

Code: Select all

"C:\Program Files\7-Zip\7z.exe" e -y "%3\%2\*.rar" -o"%3\%2"
(The "no space" between -o and the rest isn't a typo and is needed)

I haven't investigated best switches/options there at all, so maybe others would be better or e.g. nice to add for deleting source-files afterwards additionally which i'm pretty sure isn't default, and if no switch for such, then an extra line e.g. 'del "%3\%2\*.rar'. Anyway just a thought(7-zip vs winrar ;) )

Good luck.
gfdgdfhwetf
New User
New User
Posts: 4
Joined: Tue Dec 31, 2019 11:59 am

Re: How to run .bat script on torrent completion?

Post by gfdgdfhwetf »

mhertz wrote:I have setup the execute plugin to run the test logging batch-file posted above, then without further touching anything, then running a download in deluge 1.3.15 works with test batch-file, but when running a download afterwards in deluge 2.0.3 it doesn't, and no batch-file ever run and nothing in log about it.

I don't know the script you're trying to run originally(winrarextractor.bat), and also I don't wanna test with downloading rar archives because all I can find are illegal, and i'm not going to be setting up VPN in my windows VM also, sorry.

However, if you're using deluge 1.3.15 as you stated, then it should work, and I quickly looked up commands used for this on winrar's CLI version, and I think the following should work:

Code: Select all

"C:\Program Files\WinRAR\Rar.exe" -df x -y "%3\%2\*.rar"
If having winrar installed as not x64 but x32 then:

Code: Select all

"C:\Program Files (x86)\WinRAR\Rar.exe" -df x -y "%3\%2\*.rar"
(I probably could have used simply %programfiles%, but during testing I used full paths just to make sure everything was working and rule out any possible "conflict" or issue arrising).

That command-line should unpack rars, if found, in same folder where found, and delete source files afterwards.

Btw, back when I used windows many years ago, I quickly switched to 7-ZIp instead of winrar, as free(also open-source which doesn't hurt), is lighter, can compress better(with it's own 7z format, buy also simply zip archives gets roughly 10% better compression than using e.g. winzip when both set to max compression for zips) and unpack more formats, including rars, so if wanting to explore that option instead, then e.g.:

Code: Select all

"C:\Program Files\7-Zip\7z.exe" e -y "%3\%2\*.rar" -o"%3\%2"
(The "no space" between -o and the rest isn't a typo and is needed)

I haven't investigated best switches/options there at all, so maybe others would be better or e.g. nice to add for deleting source-files afterwards additionally which i'm pretty sure isn't default, and if no switch for such, then an extra line e.g. 'del "%3\%2\*.rar'. Anyway just a thought(7-zip vs winrar ;) )

Good luck.
I managed to delete the config file and now the program starts but i*m getting errors from hte Microsoft Visual C++ Runtime Lib.

Assertion Failed!
Program Deluge\lib\site-packages\gi\cairo.dll
File: cairo-surface.c
Line: 930

Expression: CAIRO_REFERENCE_COUNT_HAS_REFERENCE


Then I can choose to retry, abort or ignore but all of these options makes it crash/stop running.I also tried updating to 2.03 but the issue persists. Maybe I should try and reinstall it completely.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to run .bat script on torrent completion?

Post by mhertz »

You can try uninstall yes, though googling the error have it come up in a bunch of other reports for different programs using gtk on windows. One stated a workaround for the app in question there(inkscape) was right clicking icon and select "properties > compatibility > run as windows XP".

Also maybe you're running a specific torrent causing it, as another reported likewise error with one of his pdfs in a pdf app.
fiealch
New User
New User
Posts: 1
Joined: Wed Mar 25, 2020 10:06 am

Re: How to run .bat script on torrent completion?

Post by fiealch »

I've been using bittorrent for a while now and it's working great. After i've downloaded a torrent i've set winrar to automatically extract them. I put this in the run when torrent finishes line:

"C:\Program Files\WinRAR\UnRAR.exe" x -r "%D\*" "%D"

That's working just fine. But I would also like to run another program upon completion. This one:

sendEmail.exe -f x@x.com -t x@x.com -u subject -m %N finished downloading.

How doI make it so bittorrent will run both programs when download finishes?

Thank you.





____________________________________________________________________________________________________________________________
myccpay
Last edited by fiealch on Sat Mar 28, 2020 12:14 pm, edited 1 time in total.
Post Reply