X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=btadd;fp=btadd;h=4776e3bf54e47b7d0c7a238a06eabe95428eb266;hb=0c0ef5c73fa675decb4339fc6a858c96d0878996;hp=0000000000000000000000000000000000000000;hpb=e299213eed6a1a3eb42b6f3647b7b2890f447266;p=utils.git diff --git a/btadd b/btadd new file mode 100755 index 0000000..4776e3b --- /dev/null +++ b/btadd @@ -0,0 +1,38 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "usage: btadd [-d DIR] URL..." >&2 + exit 1 +fi + +dir="$HOME/bt" +rv=0 +while [ "$#" -gt 0 ]; do + arg="$1" + shift + if [ "$arg" = -d ]; then + dir="$1" + shift + elif [ "$arg" = -o ]; then + dir="$HOME/bt/$(date "+%y%m%d-%H%M%S")" + mkdir "$dir" + else + tfile="$(mktemp /tmp/torrentXXXXXX)" + if [ "$arg" = - ]; then + cat >"$tfile" + else + if ! wget -qO "$tfile" "$arg"; then + echo "btadd: could not fetch $arg" >&2 + rv=1 + rm "$tfile" + continue + fi + fi + if ! btcli add -d "$dir" "$tfile"; then + rv=1 + fi + rm "$tfile" + fi +done + +exit $rv