Skip to content

Instantly share code, notes, and snippets.

@kmlawson
Created October 24, 2018 21:14
Show Gist options
  • Save kmlawson/d282590e58d1c8191c1092ed8af7ca40 to your computer and use it in GitHub Desktop.
Save kmlawson/d282590e58d1c8191c1092ed8af7ca40 to your computer and use it in GitHub Desktop.
Level upped the previous script to allow download of a list of NLA maps
# assumes dezoom.sh is in the same directory
# assumes list.txt containing URLs on separate lines to each of the NLA maps
# the URL should point to the jpg to the tile in the bottom right of the seadragon zoom tiles
# NLA offers jpg and tiff download but former is low resolution and latter are way too massive in size
# echo Paste in the highest tile on zoom level 14:
listfile="/Users/kml/shell/list.txt"
lines=`cat $listfile`
totallines=`grep -c ".*" list.txt`
count=0
for line in $lines; do
let "count+=1"
echo "---------------------------------------------"
echo "File $count of $totallines total to download."
echo
fullurl=$line
zoomlevel=`echo $fullurl | sed "s/.*tile=\([0-9]\{1,2\}\)\/[0-9]\{1,2\}.*/\1/"`
echo Zoom Level Chosen:
echo $zoomlevel
myx=`echo $fullurl | sed "s/.*$zoomlevel\/\([0-9]\{1,2\}\).*/\1/"`
myy=`echo $fullurl | sed "s/.*$zoomlevel\/[0-9]\{1,2\}_\([0-9]\{1,2\}\).*/\1/"`
newurl=`echo $fullurl | sed "s/\(.*$zoomlevel\/\)[0-9]\{1,2\}_[0-9]\{1,2\}.*/\1%X_%Y.jpg/"`
imagemeta=`echo $fullurl | sed "s/\(.*\)dzi.*/\1view/"`
echo Extracting map call number from meta data at:
echo $imagemeta
mapname=`wget -q -O - $imagemeta | grep ' MAP ' | sed 's/.*\(MAP.*\)/\1/'`
if [-z "$mapname" ]
then
mapname="Map $count - Name Unkown.jpg"
fi
echo Map Name:
# Remove / and : characters from the map name:
mapname=`echo $mapname | sed "s/\///;s/://"`
echo $mapname
mapname="$mapname.jpg"
if [ -e "$mapname" ]
# Checks to see if map by this name already exists, if so prefix with count
# Some maps have multiple sheets with same map call number
then
mapname="$count-$mapname"
fi
echo Updated URL:
echo $newurl
echo Highest X tile:
echo $myx
echo Highest Y tile:
echo $myy
echo Running dezoomify...
`./dezoom.sh -o "$mapname" -X $myx -Y $myy "$newurl"`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment