600 years of paintings: Part 1
It's a lazy sunday, It's raining, it's dark, it's cold.. so I'm playing with the mediawiki API, wikipedia commons and some of my programs to fetch one painting per year since the 15th century. Here is the script:
JE=je-4.0.71.jar:
API=http://commons.wikimedia.org/w/api.php
echo "<div style='background-color:black;color:white; margin:50px; padding:50px;'>";
for CENTURY in `seq 14 19`
do
echo "<h2>${CENTURY}th century.</h2><div style='display: table;'>";
for YEAR in `seq 00 99`
do
Y=`printf "%02d" $YEAR`
java -cp ${JE}:wpsubcat.jar org.lindenb.mwtools.WPSubCat -api ${API} -d 1 -ns 6 -add "Category:${CENTURY}${Y}_paintings" -log-level OFF |\
grep -v "Category" |\
shuf |\
head -n1 |\
java -jar wpimages.jar -api ${API} -w 150 -H 150 -log-level OFF |\
gawk -F ' ' '{ name=substr($1,6);
printf("<span><div><a href=\"http://commons.wikimedia.org/wiki/%s\"><img src=\"%s\" alt=\"%s\" title=\"%s\" style=\"border: none;\"/></a><br/><b>__DATE__</b><br/>%s</div></span>\n",$1,$9,name,name,substr(name,1,20));
}'|\
sed "s/__DATE__/$CENTURY$Y/"
done
echo "</div>";
done
echo "</div>";
API=http://commons.wikimedia.org/w/api.php
echo "<div style='background-color:black;color:white; margin:50px; padding:50px;'>";
for CENTURY in `seq 14 19`
do
echo "<h2>${CENTURY}th century.</h2><div style='display: table;'>";
for YEAR in `seq 00 99`
do
Y=`printf "%02d" $YEAR`
java -cp ${JE}:wpsubcat.jar org.lindenb.mwtools.WPSubCat -api ${API} -d 1 -ns 6 -add "Category:${CENTURY}${Y}_paintings" -log-level OFF |\
grep -v "Category" |\
shuf |\
head -n1 |\
java -jar wpimages.jar -api ${API} -w 150 -H 150 -log-level OFF |\
gawk -F ' ' '{ name=substr($1,6);
printf("<span><div><a href=\"http://commons.wikimedia.org/wiki/%s\"><img src=\"%s\" alt=\"%s\" title=\"%s\" style=\"border: none;\"/></a><br/><b>__DATE__</b><br/>%s</div></span>\n",$1,$9,name,name,substr(name,1,20));
}'|\
sed "s/__DATE__/$CENTURY$Y/"
done
echo "</div>";
done
echo "</div>";
No comments:
Post a Comment