meow.sh/run

41 lines
743 B
Plaintext
Raw Permalink Normal View History

2013-05-25 19:15:43 -07:00
#!/usr/bin/env bash
2013-05-26 11:09:39 -07:00
SRCDIR="$(readlink -f "$(dirname "$0")" )"
# TODO: a way to pass opts to transmission-remote
declare -a actions
2014-03-15 14:32:44 -07:00
while getopts 'ap' opt; do
2014-03-15 08:37:34 -07:00
case $opt in
a) actions+=(addtorrent);;
p) actions+=(prettify);;
2014-03-15 14:32:44 -07:00
?) echo -E "usage: $0 [-ap]" >&2
return 1;;
2014-03-15 08:37:34 -07:00
esac
done
2013-05-25 19:15:43 -07:00
prettify() {
echo -E "$3"$'\n'"dl:"$'\t'"$URL_DOWNLOAD$2"$'\n'"at:"$'\t'"$(date -d @"$1")"
}
addtorrent() {
transmission-remote -a "$URL_DOWNLOAD$2"
2013-05-25 19:15:43 -07:00
}
2013-05-26 11:09:39 -07:00
. "$SRCDIR/meow.sh"
2013-05-25 19:15:43 -07:00
. 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