#!/bin/bash
mkdir meta
for LINK in `cat ~/mt-skiny2.txt`; do
wget http://novask.in/$LINK.png
TITLE=`curl -L http://minecraft.novaskin.me/skin/$LINK/ 2>/dev/null | grep \<title\>|sed "s/\<title\>\([^<]*\) - NovaSkin gallery - Minecraft Skins.*/\1/"`
if [ "$TITLE" != " <>" ]; then
JMENO=`echo $TITLE | sed "s/ <>//"`
# first, strip underscores
CLEAN=${JMENO//_/}
# next, replace spaces with underscores
CLEAN=${CLEAN// /_}
# now, clean out anything that's not alphanumeric or an underscore
CLEAN=${CLEAN//[^a-zA-Z0-9_]/}
# finally, lowercase with TR
CLEAN=`echo -n $CLEAN | tr A-Z a-z`
echo "name = \"$CLEAN\"," > meta/$LINK.txt
echo "author = \"http://minecraft.novaskin.me/skin/$LINK/\"," >> meta/$LINK.txt
echo "description = \"\"," >> meta/$LINK.txt
echo "comment = \"\"," >> meta/$LINK.txt
echo "" >> meta/$LINK.txt
else
echo "name = \"J. Doe\"," > meta/$LINK.txt
echo "author = \"http://minecraft.novaskin.me/skin/$LINK/\"," >> meta/$LINK.txt
echo "description = \"\"," >> meta/$LINK.txt
echo "comment = \"\"," >> meta/$LINK.txt
echo "" >> meta/$LINK.txt
fi
done