git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1095
959494ce-11ee-0310-bf91-
de5d638817bd
--- /dev/null
+#!/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
--- /dev/null
+#!/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