#! /bin/bash # cat list.html | cut -d '"' -f 6 > list.txt # Need to clean if [ -z "$1" ]; then echo "$0 " exit -1 fi list="$1" listname="$(basename $list .txt)" if [ ! -f "$list" ]; then echo "List "$list" is not found" exit -1 fi if [[ "$list" =~ "velo" ]]; then url_nonu="http://openmtbmap.org/?s2member_file_download=odbl/nonunicode/english" url="http://ftp5.gwdg.de/pub/misc/openstreetmap/openmtbmap/odbl/velomap" else url_nonu="http://openmtbmap.org/?s2member_file_download=odbl/nonunicode/english" url="http://ftp5.gwdg.de/pub/misc/openstreetmap/openmtbmap/odbl" fi if [ ! -f "cookies.jar" ]; then curl -d log="csa7fff" -d pwd="$(cat .pass)" -d rememberme="forever" --cookie-jar ./cookies.jar https://openmtbmap.org/wp-login.php &> /dev/null [ $? -ne 0 ] && { echo "Login failed"; exit 1; } fi mkdir -p downloads for name in $(cat $list); do [ -f downloads/$name ] && continue # Try first non-unicode fail=0 curl -L --cookie cookies.jar "$url_nonu/$name" -o "downloads/$name" &> /dev/null if [ $? -ne 0 ]; then fail=1 else size=$(du -sm "downloads/$name" | awk '{ print $1 }') [ $size -lt 2 ] && fail=1 fi if [ $fail -ne 0 ]; then rm -f downloads/$name fail=0 curl -o downloads/$name $url/$name &> /dev/null if [ $? -ne 0 ]; then fail=1 else size=$(du -sm "downloads/$name" | awk '{ print $1 }') [ $size -lt 2 ] && fail=1 fi [ $fail -ne 0 ] && echo "*** Failed ***: $name" [ $fail -eq 0 ] && echo "Unicode version: $name" else echo "Non-unicode version downloaded: $name" fi done