forked from wseedbox/deluge-to-rtorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deluge_to_rtorrent.sh
executable file
·80 lines (64 loc) · 1.95 KB
/
deluge_to_rtorrent.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
if [[ -z "${SKIP_SLEEP+x}" ]]; then
sleep 900
fi
torrentid=$1
torrentname=$2
torrentpath=$3
tmpdir=$(/usr/bin/mktemp -d)
##############################################################
# Define these vars to the path where they are located
##############################################################
dc=/usr/bin/deluge-console
deluge_state_dir=/home/woodsdog/.config/deluge/state
rtfr=/home/woodsdog/bin/rtorrent_fast_resume.pl
rtxmlrpc=/home/woodsdog/bin/rtxmlrpc
torrent_download_dir=/home/woodsdog/torrents/downloads
xmlrpc=/usr/bin/xmlrpc
xmlrpc_endpoint=127.0.0.1
xmlrpc_command="${xmlrpc} ${xmlrpc_endpoint}"
##############################################################
function on_exit() {
rm -rf "${tmpdir}"
}
#trap on_exit EXIT
function set_tracker {
case $1 in
*alpharatio*)
tracker=ar
;;
*empire*|*stackoverflow*|*iptorrent*)
tracker=ipt
;;
*torrentleech*)
tracker=tl
;;
*)
tracker=$1
;;
esac
}
tracker_line=$($dc info $torrentid | grep "^Tracker" | awk -F: '{print $2}' | tr -d " ")
set_tracker $tracker_line
ratio=$($dc info $torrentid | grep Ratio: | awk -F "Ratio: " '{print $2}')
#echo $tracker
#echo $ratio
#echo $ratio_rounded_down
cp ${deluge_state_dir}/${torrentid}.torrent ${tmpdir}
$rtfr $torrent_download_dir ${deluge_state_dir}/${torrentid}.torrent ${tmpdir}/${torrentid}_fast.torrent
if [[ $? -ne 0 ]]; then
echo "Something went wrong when converting the torrent file with $(basename ${rtfr})"
echo "exiting..."
exit 10
fi
# remove the torrent from deluge
$dc rm $torrentid
#$rtxmlrpc load_start ${tmpdir}/${torrentid}_fast.torrent
#sleep 3
#$rtxmlrpc d.set_custom1 ${torrentid} ${tracker}
#$rtxmlrpc d.set_custom ${torrentid} deluge_ratio ${ratio}
$xmlrpc_command load_start ${tmpdir}/${torrentid}_fast.torrent
sleep 3
$xmlrpc_command d.set_custom1 ${torrentid} ${tracker}
$xmlrpc_command d.set_custom ${torrentid} deluge_ratio ${ratio}
/usr/bin/rm -rf $tmpdir