From: fredrik Date: Sun, 12 Aug 2007 01:36:54 +0000 (+0000) Subject: Added {r,}btadd. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=0c0ef5c73fa675decb4339fc6a858c96d0878996;p=utils.git Added {r,}btadd. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1095 959494ce-11ee-0310-bf91-de5d638817bd --- 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 diff --git a/rbtadd b/rbtadd new file mode 100755 index 0000000..3dad05a --- /dev/null +++ b/rbtadd @@ -0,0 +1,16 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "usage: btadd URL..." >&2 + exit 1 +fi + +for file in "$@"; do + if [ -r "$file" ]; then + rsc pc17 btadd -o - <"$file" && rm -f "$file" + elif [[ "$file" == http*://* ]]; then + rsc pc17 btadd -o "$file" + else + echo "rbtadd: $file: unreadable" >&2 + fi +done