meow.sh/run

42 lines
829 B
Plaintext
Raw 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
while getopts 'aph' opt; do
case $opt in
a) actions+=(addtorrent);;
p) actions+=(prettify);;
?) echo -E "usage: $0 [-ap]" 1>&2;;
esac
done
2013-05-25 19:15:43 -07:00
prettify() {
echo -E "$1"$'\n'"dl:"$'\t'"$2"$'\n'"at:"$'\t'"$(date -d @"$3")"
}
declare -a torrents
addtorrent() {
torrents+=("$2")
}
runactions() {
[ ${#actions} = 0 ] && {
cat
return
}
2013-05-25 19:15:43 -07:00
while IFS=$SEP read -r title torrent time; do
for a in "${actions[@]}"; do
"$a" "$title" "$torrent" "$time"
done
2013-05-25 19:15:43 -07:00
done
for t in "${torrents[@]}"; do transmission-remote -a "$t"; done
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
[ -e times.sh ] && { . times.sh; mv times.sh times.sh.old; }
runall | runactions
exit ${PIPESTATUS[0]}