Skip to content

Instantly share code, notes, and snippets.

@hschne
Last active May 9, 2016 07:41
Show Gist options
  • Save hschne/8b9e72980ed3c60efca47ef4836db5ea to your computer and use it in GitHub Desktop.
Save hschne/8b9e72980ed3c60efca47ef4836db5ea to your computer and use it in GitHub Desktop.
#!/bin/bash
function usage()
{
echo "Available parameters:"
echo "---------------------"
echo "-h --help"
echo "-d|--date: Date used in aurora link, e.g. 20160315"
echo "-c|--count: Amount of slides available, default is 10"
echo "-o|-output: Name of output file. Default is output.pdf"
echo ""
}
# read the options
TEMP=`getopt -o d:c:o:h --long date:,count:,output:,--help -n 'aurora.sh' -- "$@"`
eval set -- "$TEMP"
# extract options and their arguments into variables.
while true ; do
case "$1" in
-h|--help)
usage ; exit 1;;
-d|--date)
case "$2" in
"") shift 2 ;;
*) DATE=$2 ; DATE_PRESENT=1; shift 2 ;;
esac ;;
-c|--count)
case "$2" in
"") shift 2 ;;
*) COUNT=$2 ; COUNT_PRESENT=1;shift 2 ;;
esac ;;
-o|--output)
case "$2" in
"") shift 2 ;;
*) OUTPUT=$2 ; OUTPUT_PRESENT=1;shift 2 ;;
esac ;;
--) shift ; break ;;
*) echo "Invalid arguments"; usage ; exit 1 ;;
esac
done
if [[ $DATE_PRESENT -ne 1 ]]; then
echo "Error: Mandatory parameter date missing"
echo
usage
exit 1
fi
if [[ $COUNT_PRESENT -ne 1 ]]; then
echo "Error: Mandatory parameter count missing"
echo
usage
exit 1
fi
if [[ $OUTPUT_PRESENT -ne 1 ]]; then
echo "Error: Mandatory parameter output missing"
echo
usage
exit 1
fi
echo "Downloading images...."
for i in `seq 1 $COUNT`; do
url="https://aurora.iguw.tuwien.ac.at/static/slides/hci/jpg/vo"$DATE"_"$i".jpg"
content="$(curl -w "%{http_code}" "$url" -o "#$i.jpg" --insecure)"
done
echo "Converting to pdf..."
convert "*.jpg" "$OUTPUT"
echo "Removing image files..."
rm *.jpg
echo "Done, saved as $output.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment