first commit
This commit is contained in:
43
old/st-weechatlinks.old
Executable file
43
old/st-weechatlinks.old
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
all="$(perl -pe 's/[^│]*([^│]*?)│/\1/' |
|
||||
perl -pe 's/^.*?\| //' |
|
||||
sed 's/ │.*//' |
|
||||
head -n-2 | tr -d '\n'|
|
||||
grep -aEo '(<[^]>]*>|\[[^ ]*\])' |
|
||||
grep -Ev "<(Unable to|Message redacted)" )" #filter out <Unable to decrypt: and <Message redacted by: <user>...
|
||||
[ -z "$all" ] && exit
|
||||
filenames="$( echo "$all" | grep -E '^<[^>]*>' | tr -d '<>')"
|
||||
links="$( echo "$all" | grep -E '^\[' | tr -d [])"
|
||||
echo "filenames:$filenames"
|
||||
echo "links:$links"
|
||||
|
||||
|
||||
choice="$(echo "$filenames" | tac | dmenu -i -p 'open which file?' -l 10)"
|
||||
[ -z "$choice" ] && exit
|
||||
|
||||
#TODO: check for robustness of multifile support
|
||||
echo "$choice" | while read -r choiceline; do
|
||||
linenr="$(echo "$filenames" | awk "/$choiceline/ {print NR}")"
|
||||
#TODO: fix this stupid implementation, what if both were selected?
|
||||
if [ "$(echo "$linenr" | wc -l)" -gt 1 ]; then
|
||||
#if [ "$(echo "$choice" | grep -cE "^$choiceline$")" -eq "$(echo "$linenr" | wc -l)" ]; then
|
||||
# true
|
||||
#else
|
||||
notify-send "weechatdl" "Multiple files by that name, choose by URL"
|
||||
link="$(echo "$links" | tac | dmenu -i -p 'open which file?' -l 10)"
|
||||
#fi
|
||||
fi
|
||||
link="$(echo "$links" | awk "NR==$linenr")"
|
||||
|
||||
echo "link:$link"
|
||||
if [ "$(echo "$link" | wc -l)" -eq 1 ]; then
|
||||
if echo "$link" | grep -qE '^emxc'; then
|
||||
matrix_decrypt --plumber rifle "$link" #"/tmp/$choiceline"
|
||||
else
|
||||
curl -L "$link" -o "/tmp/$choiceline"
|
||||
rifle "/tmp/$choiceline"
|
||||
fi
|
||||
else
|
||||
notify-send "weechatdls" "multi-link downloads not yet supported"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user