tpb: start transmission-daemon if it is not running
This commit is contained in:
parent
cb1975a91b
commit
832f1b3223
1 changed files with 18 additions and 13 deletions
31
.scripts/tpb
31
.scripts/tpb
|
@ -11,6 +11,7 @@
|
||||||
# you can add -- at the end to indicate end of options
|
# you can add -- at the end to indicate end of options
|
||||||
# (if your program supports it, most do)
|
# (if your program supports it, most do)
|
||||||
program='/usr/bin/transmission-remote -a'
|
program='/usr/bin/transmission-remote -a'
|
||||||
|
daemon='transmission-daemon'
|
||||||
TPB="https://thepiratebay.org"
|
TPB="https://thepiratebay.org"
|
||||||
|
|
||||||
# show N first matches by default
|
# show N first matches by default
|
||||||
|
@ -140,22 +141,26 @@ if [ -z "$down" ] ; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# download all torrents in list
|
# starts daemon if it was not already running and download all torrents in list
|
||||||
echo -n "Downloading torrent(s): "
|
echo -n "Downloading torrent(s): "
|
||||||
for torrent in $down ; do
|
if ! [ "$(pidof $daemon)" ]; then
|
||||||
# check if ID is valid and in range of results, download torrent
|
$daemon
|
||||||
if [ $torrent -ge 1 ] ; then
|
for torrent in $down ; do
|
||||||
if [ $torrent -le $limit ] ; then
|
# check if ID is valid and in range of results, download torrent
|
||||||
echo -n "$torrent "
|
if [ $torrent -ge 1 ] ; then
|
||||||
command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`"
|
if [ $torrent -le $limit ] ; then
|
||||||
status=$(eval "$command" 2>&1)
|
echo -n "$torrent "
|
||||||
if [ $? -ne 0 ] ; then
|
command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`"
|
||||||
echo -n '(failed!) '
|
status=$(eval "$command" 2>&1)
|
||||||
report="$report\n(#$torrent) $status"
|
if [ $? -ne 0 ] ; then
|
||||||
|
echo -n '(failed!) '
|
||||||
|
report="$report\n(#$torrent) $status"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
done
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ -n "$report" ] ; then
|
if [ -n "$report" ] ; then
|
||||||
echo -n "Exited with errors:"
|
echo -n "Exited with errors:"
|
||||||
|
|
Loading…
Reference in a new issue