Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on complete script #494

Closed
shani149 opened this issue May 1, 2018 · 3 comments
Closed

on complete script #494

shani149 opened this issue May 1, 2018 · 3 comments

Comments

@shani149
Copy link

shani149 commented May 1, 2018

Complete torrents once finished, are not being removed. I have used this script in a non-docker environment previously without any issue. i can see script being called but nothing happens.

I have following configurations in the docker-compose file:

  - TRANSMISSION_SCRIPT_TORRENT_DONE_ENABLED=true
  - TRANSMISSION_SCRIPT_TORRENT_DONE_FILENAME=/scripts_dir/transmission-purge-completed.sh

/scripts_dir is defined in the volume to the folder where the script is.

script is as follows:
`
#!/bin/sh

the folder to move completed downloads to

port, username, password

#SERVER="9091 --auth transmission:transmission"
SERVER="9091 "

echo "Starting on port #$SERVER"

use transmission-remote to get torrent list from transmission-remote list

use sed to delete first / last line of output, and remove leading spaces

use cut to get first field from each line

TORRENTLIST=transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=" " --fields=1

transmission-remote $SERVER --list

for each torrent in the list

for TORRENTID in $TORRENTLIST
do
echo Processing : $TORRENTID

# check if torrent download is completed
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`

# check torrents current state is
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
echo $STATE_STOPPED

# if the torrent is "Stopped", "Finished", or "Idle after downloading 100%"
if [ -n "$DL_COMPLETED" ] && [ -n "$STATE_STOPPED" ]; then
    # move the files and remove the torrent from Transmission
    echo "Torrent #$TORRENTID is completed"
    echo "Removing torrent from list"
    transmission-remote $SERVER --torrent $TORRENTID --remove
else
    echo "Torrent #$TORRENTID is not completed. Ignoring. is_COMPLETED:$DL_COMPLETED STATE:$STATE_STOPPED"
fi

done`

@shani149
Copy link
Author

shani149 commented May 1, 2018

figured it out, had to provide auth parameters.

@shani149 shani149 closed this as completed May 1, 2018
@ljunglex
Copy link

Thanks, this helped me as well.

@lastb0isct
Copy link

lastb0isct commented Dec 8, 2019

Just to confirm...is this what your transmission-purge-completed.sh looks like:

#!/bin/sh

#SERVER="9091 --auth transmission:transmission"
SERVER="9091 "

echo "Starting on port #$SERVER"

TORRENTLIST=transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=" " --fields=1

for each torrent in the list
for TORRENTID in $TORRENTLIST
do
echo Processing : $TORRENTID

# check if torrent download is completed
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`

# check torrents current state is
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
echo $STATE_STOPPED

# if the torrent is "Stopped", "Finished", or "Idle after downloading 100%"
if [ -n "$DL_COMPLETED" ] && [ -n "$STATE_STOPPED" ]; then
    # move the files and remove the torrent from Transmission
    echo "Torrent #$TORRENTID is completed"
    echo "Removing torrent from list"
    transmission-remote $SERVER --torrent $TORRENTID --remove
else
    echo "Torrent #$TORRENTID is not completed. Ignoring. is_COMPLETED:$DL_COMPLETED STATE:$STATE_STOPPED"
fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants