#!/bin/bash
#                       /usr/local/bin/youjpg
#  http://crystalfaeries.net/posix/bin/youjpg
# celeste:crystalfaery 2016-02-05 01:27:25+00:00
# Fetch the "cover" jpg for a youtube video
# Input is the 11 character hash code uniquely identifying the video

while [ $# -ne 0 ]
do
	for i in {0..9}
	do
		wget -O "$1"."$i".jpg https://img.youtube.com/vi/$1/"$i".jpg 
	done
	find "$1".?.jpg -size 0 -exec rm {} \;
	shift
done


syntax highlighted by Code2HTML, v. 0.9.1