summaryrefslogtreecommitdiff
path: root/bin/menuscripts
diff options
context:
space:
mode:
Diffstat (limited to 'bin/menuscripts')
-rwxr-xr-xbin/menuscripts/tsh13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh
index d07d0d5..ea582d8 100755
--- a/bin/menuscripts/tsh
+++ b/bin/menuscripts/tsh
@@ -42,7 +42,7 @@ cleanup() {
list_modules() { find -L "$MODULES_PATH" -type f -printf "%f\n"; }
-trap "exit 1" INT
+trap "exit 2" INT
trap "cleanup" EXIT
## OPTIONS
@@ -103,7 +103,7 @@ for p in $deps; do
error=1
fi
done
-[ "${error:-0}" -eq 1 ] && exit 1
+[ "${error:-0}" -eq 1 ] && exit 3
# Get the torrents with module
if [ "${skip:-0}" -eq 1 ]; then
@@ -119,7 +119,7 @@ else
head -n 1
fi | tr ' ' '+'
)"
- [ "$query" ] || exit 1
+ [ "$query" ] || exit 4
# shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091
. "$MODULES_PATH/$module"
@@ -132,6 +132,7 @@ else
printf "%s\n" "$module" >>"$links"
fi
+# Default sorting if unset
command -v sort_results >/dev/null || sort_results() { sort -k3 -n -r; }
# select result from "$results"
@@ -147,7 +148,7 @@ for choice in $(
printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)"
magnet="$(get_magnet "$choice")"
- [ "$magnet" ] || exit 1
+ [ "$magnet" ] || exit 5
if [ -z "$noaskfiles" ] && confirm 'files?'; then
hash="${1##*btih:}"
@@ -159,9 +160,9 @@ for choice in $(
rm -f "$tmp"/.torrent
fi
- if [ "$noaskdownload" ] || confirm 'download?'; then
+ if [ -z "$noaskdownload" ] && confirm 'download?'; then
[ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)"
- [ "$category" ] || exit 2
+ [ "$category" ] || exit 6
transmission-remote debuc.com -a "$magnet" -w "/downloads/$category"
elif confirm "copy?"; then
echo "$magnet" | clipp