"Run external program on torrent completion" is not working

If you run qBittorrent in / with Docker.
Post Reply
bszabo

"Run external program on torrent completion" is not working

Post by bszabo »

I have qBittorrent set up in a docker container running on RPi, here's my compose information:

Code: Select all

---
version: "2.1"
services:
  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent
    container_name: qbittorrent
    environment:
      - PUID=[myUID]
      - PGID=[myGID]
      - TZ=Europe/Stockholm
      - WEBUI_PORT=8080
    volumes:
      - [myConfigFolder]:/config
      - [myMoviesFodler]:/movies
      - [myTVShowsFolder]:/tv_shows
    ports:
      - 6881:6881
      - 6881:6881/udp
      - 8080:8080
    restart: unless-stopped
And I want to run a bash script when a torrent is completed, here's a script that I'm using for testing:
\config\custom-scripts\test.sh

Code: Select all

#!\bin\bash
echo "Torrent name: $1, Content path: $2, Rooth path: $3, Save path: $4" > testNames.txt
I set its permission to 755 and if I run it from the container's terminal it runs just fine.

But when I set up in the qBittorrent to run it after a torrent completed, nothing happens.
I set up the command like this:

Code: Select all

bash /config/custom-scripts/test.sh "%N" "%F" "%R" "%D"
Based on the logs (see below) it seems like that there was an attempt to execute the script but something doesn't work, since the file is not created as it should be.

Code: Select all

(N) 2023-02-04T19:06:45 - Torrent: [torrentName], running external program, command: bash /config/custom-scripts/test.sh "[torrentName]" "/movies/[torrentName]" "/movies/[torrentName]" "/movies"
Any idea what is wrong or some way to debug it and find out what goes wrong?
Guibuu

Re: "Run external program on torrent completion" is not working

Post by Guibuu »

I have the same problem.

I've tried with qbittorrentofficial/qbittorrent-nox and linuxserver/qbittorrent with the same results.

1. I bound in the container the /test folder and gave it the correct permissions.
2. In qBittorrent > Options > Run external program on torrent finished I write touch /test/"%N".txt
3. I download some torrent, for example LibreOffice_7.5.0_Win_x86-64_helppack_en-GB.msi
4. When the torrent finishes, in /test appears the file _8L2JY~H.TXT, so I think qBittorrent is passing the parameters incorrectly.
zargas

Re: "Run external program on torrent completion" is not working

Post by zargas »

Hi,
I have exactelly the same issue with the option "Run external program", nothing works ! :'( :'( :'(

I don't now how to run script on torrent finish !

Are you still stuck at this step ?

I use qBittorrent v4.5.2 Web UI (64-bit) docker on Unraid.
zargas

Re: "Run external program on torrent completion" is not working

Post by zargas »

zargas wrote: Thu Mar 23, 2023 12:08 pm Hi,
I have exactelly the same issue with the option "Run external program", nothing works ! :'( :'( :'(

I don't now how to run script on torrent finish !

Are you still stuck at this step ?

I use qBittorrent v4.5.2 Web UI (64-bit) docker on Unraid.
For me, the script was run, but it was a wrong permission on a folder. I changed the owner and it seem's to work, now let's go for the true script !
xupetas

Re: "Run external program on torrent completion" is not working

Post by xupetas »

Hi,

Same issue here:

Here it did not run:

qbittorrent.log.bak1619:(N) 2023-03-16T20:07:45 - Added new torrent. Torrent: "The Evaluation"
qbittorrent.log.bak1629:(N) 2023-03-16T23:49:10 - Enqueued torrent move. Torrent: "The Evaluation". Source: "/mnt/slice/slice0/torrents.tmp". Destination: "/mnt/slice/slice1/staging"
qbittorrent.log.bak1629:(N) 2023-03-16T23:49:19 - Torrent reached the share ratio limit. Removed torrent. Torrent: "The Evaluation".
qbittorrent.log.bak1629:(N) 2023-03-16T23:51:24 - Removed torrent. Torrent: "The Evaluation"

Here it did:

qbittorrent.log:(N) 2023-04-09T11:14:52 - Running external program. Torrent: "Erica Duchess My Spirit Told Me (2022) [1080p] [WEBRip] [YTS.MX]". Command: `/usr/bin/bash /pub/p2p/qbittorrent/external.sh '/mnt/slice/slice1/staging/Erica Duchess My Spirit Told Me (2022) [1080p] [WEBRip] [YTS.MX]' 'RSS' 'Erica Duchess My Spirit Told Me (2022) [1080p] [WEBRip] [YTS.MX]' 81c8841bacd54ee96169d924080e6b9f46f92cee`

What am i missing?
iRobot73

Re: "Run external program on torrent completion" is not working

Post by iRobot73 »

I cobbled a .SH to move things around upon completion (allowing seeding of the original files to 1:1, then deleting the files). Took a bit of trial-n-error

'Upon completion' (add/remove as you want/need):

Code: Select all

/bin/bash /scripts/complete.sh -n "%N" -l "%L" -f "%F" -r "%R" -c "%D" -c %C -z %Z -i "%I" -j "%J" -k "%K"
Updated the process to use flags so order passed to script won't matter

Been keeping track of all iterations via GitHub

Outputs all the parameters for easy validation/tweaking. Not the prettiest output but, IMO, easy enough to follow

Code: Select all

[2023-08-12T13:54:13-04:00]  ++ echo 'ERROR: An error occurred during execution, check log /scripts/12-08-2023_log.txt for details.'
+ trap 'echo '\''ERROR: An error occurred during execution, check log /scripts/12-08-2023_log.txt for details.'\'' >&3' ERR
+ trap '{ set +x; } 2>/dev/null; echo -n "[$(date -Is)]  "; set -x' DEBUG
[2023-08-12T14:04:02-04:00]  + echo 'Torrent: '\''Python Programming And Machine Learning Understanding How To Code Within 24 Hours 2 In 1'\'''
[2023-08-12T14:04:02-04:00]  + echo '     Category    : ePubs'
[2023-08-12T14:04:02-04:00]  + echo '     Files       : 4'
[2023-08-12T14:04:02-04:00]  + echo '     Size        : 6641422'
[2023-08-12T14:04:02-04:00]  + echo '     Save Path   : /downloads/ePubs'
[2023-08-12T14:04:02-04:00]  + echo '     Content Path: /downloads/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1'
[2023-08-12T14:04:02-04:00]  + echo '     Root Path   : /downloads/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1'
[2023-08-12T14:04:02-04:00]  + CopyFiles
+ local DEST_PATH=/downloads/complete
+ [[ ePubs != '' ]]
+ DEST_PATH=/downloads/complete/ePubs
+ [[ ! -e /downloads/complete/ePubs ]]
+ mkdir /downloads/complete/ePubs
+ chown -R abc:abc /downloads/complete/ePubs
+ chmod -R 777 /downloads/complete/ePubs
+ [[ /downloads/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1 != '' ]]
+ cp -R '/downloads/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1' /downloads/complete/ePubs
+ FINAL_DEST='/downloads/complete/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1'
[2023-08-12T14:04:02-04:00]  + chown -R abc:abc '/downloads/complete/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1'
[2023-08-12T14:04:02-04:00]  + chmod -R 777 '/downloads/complete/ePubs/Python Programming And Maching Learning Understanding How To Code Within 24 Hours 2 In 1'
Attachments
Screenshot from 2023-08-12 23-39-12.png
Screenshot from 2023-08-12 23-39-12.png (128.67 KiB) Viewed 2859 times
whitebeard
Newbie
Newbie
Posts: 4
Joined: Sat Jul 17, 2021 10:06 am

Re: "Run external program on torrent completion" is not working

Post by whitebeard »

I have same problem.
I used to run a sound file to tell me a download had finished.
I put this in Run on torrent finished: D:/Sound Files/Another One Bites The Dust.mp3.
It worked fine for years until recently. I tried enclosing it in quotes, no help.
Any ideas?
Post Reply