Migrating to Deluge from Transmission

This commit is contained in:
DarkFeather
2017-05-17 16:12:56 -05:00
parent 62e0619988
commit 19055bacfd
3 changed files with 56 additions and 51 deletions

View File

@@ -1,5 +1,7 @@
#!/bin/bash
source /usr/local/src/SharedLibraries/Bash/header
export downloadtorrent="sudo -u deluge deluge-console add"
if [ -z "$3" ]; then
configuretorrent /usr/local/etc/WolfPack/torrentengine
else
@@ -18,31 +20,36 @@ function helptext {
// /~_____/ with their prey.
/// \\/ / ~dev@aninix.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wolfpack --alpha [enginefile] ~~ Tell the alpha to send the
pack members hunting.
wolfpack --member <pup> [enginefile] ~~ Send a member to train a pup
and bring back results.
wolfpack --help ~~ Show this helptext
wolfpack --alpha [enginefile] ~~ Tell the alpha to send the
pack members hunting.
wolfpack --member <pup> [enginefile] ~~ Send a member to train a
pup and bring back results.
Optionally provide a
torrent engine file.
wolfpack --torrent-monitor ~~ Pull up the Deluge console
for torrents.
wolfpack --reset-log ~~ Clear the wolfpack log. This
is in /var/log/wolfpack.log.
wolfpack --help ~~ Show this helptext
Available pup types (all pups are line-delimited with the type and
result location as the first two lines):
torrent ~~ Torrent the result of the
search term.
Will remove search line on
success.
shows ~~ Download the episode in a
show and increment. Shows
are listed in format
S01E01#Show terms
download ~~ Takes a list of commands to
run to arrive at a URL to
grab and downloads the last
URL.
search ~~ Uses the Google search
engine to return the top
five results for the search
terms on each line.
'
Available pup types (all pups are line-delimited with the type and
result location as the first two lines):
torrent ~~ Torrent the result of the
search term. Will remove search line on
success.
shows ~~ Download the episode in a
show and increment. Shows
are listed in format
S01E01#Show terms#modifier
download ~~ Takes a list of commands to
run to arrive at a URL to
grab and downloads the last
URL.
search ~~ Uses the Google search
engine to return the top
five results for the search
terms on each line.
'
}
function privacycheck {
@@ -61,31 +68,20 @@ function nextairdate {
return
}
function transmissioncheck {
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a "$logfile"
exit 0;
fi
}
function torrent {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument."
return;
fi
transmissioncheck;
privacycheck;
export downloaddir=$(head -n 2 "$1" | tail -n 1)
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a "$logfile"
return;
fi
for i in $(tail -n +3 "$1"); do
getmagnetlink "$i"
if [ "$magnetlink" != "" ]; then
/usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
/bin/bash -c "$downloadtorrent $magnetlink"
sed -i "/$i/d" "$1"
echo Downloaded and removed $i | tee -a "$logfile"
echo $magnetlink | tee -a "$logfile"
echo Added magnet to deluged and removed $i | tee -a "$logfile"
fi
done
if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi
@@ -96,7 +92,6 @@ function shows {
echo "Need a valid argument."
return;
fi
transmissioncheck;
privacycheck;
export downloaddir=$(head -n 2 "$1" | tail -n 1)
echo "Would download to "$downloaddir
@@ -116,13 +111,10 @@ function shows {
if [ "$magnetlink" != "" ]; then
# We found an episode.
echo $i | tee -a "$logfile"
/usr/bin/transmission-cli -d 300 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
echo $magnetlink | tee -a "$logfile"
/bin/bash -c "$downloadtorrent $magnetlink"
sed -i "s/$i/S${season}E${newep}#${showName}#${modifier}/" "$1"
echo Downloaded and pup updated. | tee -a "$logfile"
rm -Rf ~/.config/transmission/resume/*
rm -Rf ~/.config/transmission/torrents/*
rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Yggdrasil
rm -f "$downloaddir"/*/*.nfo
echo | tee -a "$logfile"
else
# We didn't -- is there a new season?
@@ -133,7 +125,8 @@ function shows {
fi
if [ "$magnetlink" != "" ]; then
echo "S${newseason}E01" $showName | tee -a "$logfile"
/usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
echo "$magnetlink" | tee -a "$logfile"
/bin/bash -c "$downloadtorrent $magnetlink"
sed -i "s/$i/S${newseason}E01#$showName#$modifier/" "$1"
else
nextAirDate="$(nextairdate "$showName")"
@@ -239,6 +232,10 @@ case "$1" in
cat /dev/null > "$logfile"
exit 0;
;;
"--torrent-monitor")
exec sudo -u deluge deluge-console;
exit 0;
;;
*)
helptext
;;