29 lines
1005 B
Plaintext
29 lines
1005 B
Plaintext
|
#!/bin/sh
|
||
|
all="$(perl -pe 's/[^│]*([^│]*?)│/\1/' |
|
||
|
perl -pe 's/^.*?\| //' |
|
||
|
sed 's/ │.*//' |
|
||
|
head -n-3 | tr -d '\n'|
|
||
|
grep -aEo '(<[^]]*>|\[[^ ]*\])')"
|
||
|
|
||
|
filenames="$( echo "$all" | grep -E '^<[^>]*>' | tr -d '<>')"
|
||
|
links="$( echo "$all" | grep -E '^\[' | tr -d [])"
|
||
|
choice="$(printf 'most recent\nall\n%s' "$filenames" | dmenu -i -p 'open which file?' -l 10)"
|
||
|
case "$choice" in
|
||
|
"most recent") link="$(echo "$links" | tail -n1)";;
|
||
|
"all") link="$links";;
|
||
|
*) #TODO: implement dmenu multiline support
|
||
|
linenr="$(echo "$filenames" | awk "/$choice/ {print NR}")"
|
||
|
[ "$(echo "$linenr" | wc -l)" -gt 1 ] && notify-send "weechatdls" "multiple files with that name, not yet supported"
|
||
|
link="$(echo "$links" | awk "NR==$linenr")";;
|
||
|
esac
|
||
|
if [ "$(echo "$link" | wc -l)" -eq 1 ]; then
|
||
|
if echo "$link" | grep -qE '^emxc'; then
|
||
|
matrix_decrypt.py "$link"
|
||
|
else
|
||
|
curl -L "$link" -o "/tmp/$choice"
|
||
|
rifle "/tmp/$choice"
|
||
|
fi
|
||
|
else
|
||
|
notify-send "weechatdls" "multi-link downloads not yet supported"
|
||
|
fi
|