From 9c8eb6e7be5cef27dec23eaf90ee4583d19d2a75 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 5 Aug 2020 18:00:29 -0400 Subject: [PATCH] add video tweet support --- pdt.sh | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/pdt.sh b/pdt.sh index 6c44b77..93ddad3 100644 --- a/pdt.sh +++ b/pdt.sh @@ -60,7 +60,7 @@ toot() { # post to mastodon + twitter + gnu social post + diaspora # -# usage: pdt [--dbd] [-m MEDIA_FILE] [POST] +# usage: pdt [--dbd] [-m MEDIA_FILE] [-v VIDEO_PATH] [POST] pdt() { if [[ $pdttest ]]; then rbow_account=iank @@ -72,19 +72,12 @@ pdt() { mastodon_account=fsf@hostux.social fi dbd=false + video=false while [[ $1 == -* ]]; do case $1 in -m) media="$2" shift 2 - if [[ ! -e $media ]]; then - echo "error: file not found $media" - return 1 - fi - if [[ $media == *\ * ]]; then - echo "error: file path contains a space. move it to non-space path" - return 1 - fi rbow_arg=" --i $media" toot_arg="--media $media" dia_arg="-p $media " @@ -97,8 +90,23 @@ pdt() { mastodon_account=endDRM@hostux.social shift ;; + -v) + video=true + media="$2" + shift 2 + ;; esac done + if [[ $media ]]; then + if [[ ! -e $media ]]; then + echo "error: file not found $media" + return 1 + fi + if [[ $media == *\ * ]]; then + echo "error: file path contains a space. move it to non-space path" + return 1 + fi + fi # if we have no argument if (( ! $# )); then read -r -p "input PDT text: " input @@ -109,6 +117,18 @@ pdt() { echo "$input" read fi + if $video; then + local oath + oath=$HOME/.rainbow_oauth + account=fsf + if $dbd; then + account=dbd + fi + rm -f $oath + ln -s ${oath}-$account $oath + python3 ~/src/async-upload.py "$media" "$*" + return + fi fails=() if ! rbow -$rbow_account t "$*" $rbow_arg; then fails+=(tweet) @@ -142,7 +162,7 @@ pdt-setup() { mkdir -p ~/src cd ~/src - for repo in errhandle rainbowstream diaspy jan-pona-mute; do + for repo in errhandle rainbowstream diaspy jan-pona-mute video-tweet; do if [[ -e $repo ]]; then cd $repo git fetch -- 2.25.1