rudimentary weechat links scanner
This commit is contained in:
parent
83f6e0960f
commit
eaa5964611
@ -8,7 +8,7 @@ appearance.dayseparator=yes
|
||||
appearance.emptyline=yes
|
||||
appearance.notifybar=yes
|
||||
appearance.sidebarwidth=0
|
||||
appearance.theme=default on default
|
||||
appearance.theme=blue on black
|
||||
appearance.todoview=hide-completed
|
||||
appearance.headingpos=right-justified
|
||||
daemon.enable=yes
|
||||
|
@ -44,6 +44,7 @@ def main():
|
||||
description='Download and decrypt matrix attachments'
|
||||
)
|
||||
parser.add_argument('url', help='the url of the attachment')
|
||||
parser.add_argument('file', nargs='?', help='save attachment to <file>')
|
||||
parser.add_argument('--plumber',
|
||||
help='program that gets called with the '
|
||||
'dowloaded file')
|
||||
@ -68,11 +69,19 @@ def main():
|
||||
print("Error downloading file")
|
||||
return -2
|
||||
|
||||
plumber = args.plumber or "/usr/bin/rifle"
|
||||
plumber = args.plumber
|
||||
plaintext = decrypt_attachment(request.content, key, hash, iv)
|
||||
file_name = save_file(plaintext)
|
||||
|
||||
subprocess.run([plumber, "{file}".format(file=file_name)])
|
||||
if args.file is None:
|
||||
file_name = save_file(plaintext)
|
||||
if plumber is None:
|
||||
plumber = "xdg-open"
|
||||
else:
|
||||
file_name = args.file
|
||||
open(file_name, "wb").write(plaintext)
|
||||
|
||||
if plumber is not None:
|
||||
subprocess.run([plumber, file_name])
|
||||
|
||||
return 0
|
||||
|
||||
|
28
.local/bin/weechatlinks
Executable file
28
.local/bin/weechatlinks
Executable file
@ -0,0 +1,28 @@
|
||||
#!/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
|
Loading…
Reference in New Issue
Block a user