Skip to content

Instantly share code, notes, and snippets.

@donaldsteele
Created February 4, 2017 19:32
Show Gist options
  • Save donaldsteele/7969bde1b85de402a863de795fe148bb to your computer and use it in GitHub Desktop.
Save donaldsteele/7969bde1b85de402a863de795fe148bb to your computer and use it in GitHub Desktop.
Script to generate movie thumbnails and upload to imgur
#!/bin/bash
#uses mtn (movie thumbnailer) https://sourceforge.net/projects/moviethumbnail/
#requires tahoma font to be installed https://github.com/caarlos0/msfonts/blob/master/fonts/tahomabd.ttf
clientid='3e7a4deb7ac67da'
img=$(mktemp -d)
mtn -f "/usr/share/fonts/truetype/msttcorefonts/tahomabd.ttf" -c 1 -r 8 -D 6 -b 0.80 -B 240 -O $img -o'.jpg' "$1"
for f in $img/*
do
echo "Processing $f file..."
res=$(curl -sH "Authorization: Client-ID $clientid" -F "image=@$f" "https://api.imgur.com/3/upload")
echo $res | grep -qo '"status":200' && link=$(echo $res | sed -e 's/.*"link":"\([^"]*\).*/\1/' -e 's/\\//g')
echo link $link
test -n "$link" && (echo link $link | rm "$f") || echo "$res" > "$f.error"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment