Add screenshot grabbing for twitter URIs and the tools needed. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit 99ae2e7abf7c4868719d6ec1ff449390c36148d6 DIR parent a78100019f56bcf3c6a8b8c3bf95b9d883c4d8bc HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Sun, 19 Jan 2020 16:29:23 +0100 Add screenshot grabbing for twitter URIs and the tools needed. Diffstat: M annna-start-services | 16 +++++++++++++++- A screenshot-paste | 15 +++++++++++++++ A screenshot-url | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) --- DIR diff --git a/annna-start-services b/annna-start-services @@ -118,8 +118,22 @@ then then annna-say -c "#bitreich-en" "HTML title: ${urititle}" else + case "${uri}" in + *twitter.com*) + spurl="$(screenshot-paste "${uri}")" + ;; + *) + spurl="" + ;; + esac + purl="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" - annna-say -c "#bitreich-en" "content: ${purl} ; HTML title: ${urititle}" + if [ -n "${spurl}" ]; + then + annna-say -c "#bitreich-en" "content: ${purl} ; screen: ${spurl} ; HTML title: ${urititle}" + else + annna-say -c "#bitreich-en" "content: ${purl} ; HTML title: ${urititle}" + fi fi ;; esac DIR diff --git a/screenshot-paste b/screenshot-paste @@ -0,0 +1,15 @@ +#!/bin/sh + +export PATH="/home/annna/bin:$PATH" + +if [ $# -lt 1 ]; +then + printf "usage: %s url\n" "$(basename "$0")" >&2 + exit 1 +fi + +pastepath="$(screenshot-url "$1")" +pastefile="$(basename "${pastepath}")" + +printf "gopher://bitreich.org/I/p/%s\n" "${pastefile}" + DIR diff --git a/screenshot-url b/screenshot-url @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ $# -lt 1 ]; +then + printf "usage: %s url\n" "$(basename "$0")" >&2 + exit 1 +fi + +# Use Tor. +proxy="socks5://127.0.0.1:9100" +#proxy="" +export http_proxy="${proxy}" +export https_proxy="${proxy}" +export socks_proxy="${proxy}" + +url="$1" +firefoxargs="--window-size=1024,768" +pastebase="/br/gopher/paste" + +cd "${pastebase}" +tmpfile="$(mktemp p-XXXXXXXXXXXXX.png)" +firefox $firefoxargs --screenshot "${pastebase}/${tmpfile}" "${url}" 2>&1 >/dev/null + +# Firefox stores with rw---- +chmod g+wr "${pastebase}/${tmpfile}" + +printf "%s/%s\n" "${pastebase}" "${tmpfile}" +