Commit e50de018 authored by Ruben Schade's avatar Ruben Schade
Browse files

Script to generate video thumbnail posts

parent 9e08b1d8
#!/bin/sh
######
## Generate video thumbnails
## Rubenerd Industries
SERVER="rubenerd.com"
PLAY1X="../metadata/play@1x.png"
PLAY2X="../metadata/play@2x.png"
## Download video thumbnail
VIDEO=`youtube-dl --get-thumb --no-warnings $1 | tail -1`
curl -Lo "video.jpg" "$VIDEO"
## Get video title
TITLE=`youtube-dl --get-title --no-warnings $1 | tail -1`
## Get video ID
ID=`echo $1 | awk -F= '{ print $2 }'`
## Get year for archive
YEAR=`date '+%Y'`
## Generate image URLs
## TODO: Make clipboard copy work on FreeBSD, not just macOS
FILE="https://rubenerd.com/files/$YEAR/yt-$ID"
HTML="<p><a href="$1" title=\"Play $TITLE\"><img src=\"$FILE@1x.jpg\" srcset=\"$FILE@1x.jpg 1x, $FILE@2x.jpg 2x\" alt=\"Play $TITLE\" style=\"width:500px;height:281px;\" /></a>"
echo $HTML | pbcopy
## Create thumbnails
convert -resize 1000x563 "video.jpg" -quality 97 -crop 1000x562+0+0 +repage \
+page "$PLAY2X" -flatten "yt-$ID@2x.jpg"
convert -resize 500x281 "video.jpg" -quality 97 "yt-$ID@1x.jpg" \
+page "$PLAY1X" -flatten "yt-$ID@1x.jpg"
## Upload files
scp yt-$ID@*jpg $SERVER:$YEAR/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment