summary refs log tree commit diff
path: root/bin/sup.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-21 22:08:37 -0500
committerJune McEnroe <june@causal.agency>2021-02-21 22:08:37 -0500
commitc73aa0b84e1853bb7d79d027e708a4712dbc5e2e (patch)
tree54e179f03464922224b4053ae0036ec82da818e9 /bin/sup.sh
parentAdd Liberapay to sup (diff)
downloadsrc-c73aa0b84e1853bb7d79d027e708a4712dbc5e2e.tar.gz
src-c73aa0b84e1853bb7d79d027e708a4712dbc5e2e.zip
Add asciinema to sup
Diffstat (limited to 'bin/sup.sh')
-rw-r--r--bin/sup.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/sup.sh b/bin/sup.sh
index fb6ad4bf..b7f28bc7 100644
--- a/bin/sup.sh
+++ b/bin/sup.sh
@@ -11,6 +11,29 @@ copy() {
 	printf '%s' "$1" | pbcopy
 }
 
+asciinema() {
+	echo 'Fetching CSRF token...'
+	jar=$(mktemp -t sup)
+	trap 'rm "${jar}"' EXIT
+	csrf=$(
+		curl -Ss -c "${jar}" 'https://asciinema.org/login/new' |
+		sed -n 's/.*name="_csrf_token".*value="\([^"]*\)".*/\1/p'
+	)
+	echo 'Submitting form...'
+	curl -Ss -X POST -b "${jar}" \
+		-F "_csrf_token=${csrf}" -F "login[email]=${email}" \
+		'https://asciinema.org/login' \
+		>/dev/null
+	echo 'Waiting for email...'
+	url=$(
+		git fetch-email -i -M Trash \
+			-F 'hello@asciinema.org' -T "${email}" \
+			-S 'Login to asciinema.org' |
+		grep -m 1 '^https://asciinema\.org/session/new'
+	)
+	open "${url}"
+}
+
 bugzilla() {
 	echo 'Fetching CSRF token...'
 	csrf=$(