#!/usr/bin/env bash SRCDIR="$(readlink -f "$(dirname "$0")" )" # TODO: a way to pass opts to transmission-remote declare -a actions while getopts 'ap' opt; do case $opt in a) actions+=(addtorrent);; p) actions+=(prettify);; ?) echo -E "usage: $0 [-ap]" >&2 return 1;; esac done prettify() { echo -E "$3"$'\n'"dl:"$'\t'"$URL_DOWNLOAD$2"$'\n'"at:"$'\t'"$(date -d @"$1")" } addtorrent() { transmission-remote -a "$URL_DOWNLOAD$2" } . "$SRCDIR/meow.sh" . config.sh runsearch if [ "${#actions}" -eq 0 ]; then # TODO: abstract for regex in "${searchregex[@]}"; do searchfilter db.txt "${regex:1}" done else for a in "${actions[@]}"; do runfilter "$a" done fi exit 0