This script should
1. create a directory from the torrent name in a "done" folder
2. makes a $torrentname.desktop file providing a symbol in the /done/$torrentname folder which you can click to open the website where you downloaded the file
3. if the torrent is a folder, it moves the torrentfiles to the folder made in step 1 and deletes the remaining empty folder
4. if not (torrent is a file), it copies the file in the done/$torrentname folder
5. ?????
6. Profit!!!!!!!!!!!!!!!!1111!
As some torrent names are awfully long, the script just takes the first 15 chars and discards the rest. If you don't like that just change tname15 to torrentname
Edited (new version!!)
Code: Select all
#!/bin/bash
# Script that starts when the torrent is finished.
# It copies the dl-files to the done/$tname15 folder
torrentid=$1
torrentname=$2
torrentpath=$3
# Be flexible - - shorten long silly torrentnames and provide variables
tname="${torrentname%.*}"
tname15="${tname:0:15}"
# Set working dir
# cd "~/downloads/torrents/"
# creating directory from torrent name
mkdir -p "/home/derp/downloads/torrents/done/$tname15"
# making .desktop file with a link to the dl site
echo -e "[Desktop Entry]\nVersion=1.0\nType=Link\nURL=http://mybelovedtorrentsite/search/?hash=$torrentid#results" > "/home/derp/downloads/torrents/done/$tname15/$tname15.desktop"
# If folder .part/$torrentname exists mv .part/$torrentname/* to done/$tname15; delete .part/$torrentname else move .part/$torrentname to done/$tname15 fi
if [ -d "/home/derp/downloads/torrents/.part/$torrentname" ]; then
mv "/home/derp/downloads/torrents/.part/$torrentname/*" "/home/derp/downloads/torrents/done/$tname15"
wait mv
rmdir "/home/derp/downloads/torrents/.part/$torrentname"
else
mv "/home/derp/downloads/torrents/.part/$torrentname" "/home/derp/downloads/torrents/done/$tname15"
wait mv
fi
Let it execute it after a dl is done. The only problem may be that you can't force re-check the torrent. If anyone has a solution, integrated in Deluge, that would be great!
It works now, have fun with it
Edit once again!
(as of 2013-09-04)
This is the script I use now. It works well for one site (can I mention it?) but you can easily change it
The script lives in my ~/downloads/torrents/.scripts folder but can be placed somewhere else because the paths are absolute.
Code: Select all
#!/bin/bash
# Description: The script starts when a torrent is finished.
# It makes a folder named after the torrent. It then copies
# the files to the folder and creates a desktop link which
# points to the torrent on the torrentsite.
# Get the variables from Deluge:
torrentid=$1
torrentname=$2
torrentpath=$3
# Shortening long silly torrent names and provide variables for later use
tname="${torrentname%.*}"
tname25="${tname:0:25}"
# Set working dir ## does not work, using absolute pathnames -.-
# cd "~/downloads/torrents/"
# creating directory from torrent name
mkdir -p "/home/derp/downloads/torrents/done/$tname25"
# Fetching the the link ...
hashlink="$(echo "http://some-torrent-site.ws/advanced_search/?hash=$torrentid")"
link2="$( lynx -source $hashlink | grep -o 'class="icon" /> <a href=".*\Wtorrent' | grep -Po 'href="\K.*?(?=")' )"
# Making the .desktop file as a link to the dl-site
echo -e "[Desktop Entry]\nVersion=1.0\nType=Link\nURL=http://some-torrent-site.ws""$link2" > "/home/derp/downloads/torrents/done/$tname25/link2_$tname25.desktop"
# Moving the files in the folder created above
mv "/home/derp/downloads/torrents/.part/$torrentname" "/home/derp/downloads/torrents/done/$tname25"
# I don't know if I need this, but I can sleep good with it :)
wait mv
There are some things which need improvement.
- you have to change teh directory manually in Deluge in order to force re-check the torrent (Deluge: Y U NO checkin' the torrent by yourself when ready??)
- check if the torrent is a folder and if so, don't create a new one - just move it
- and more ...
If you have ideas, contact me!