#!/bin/bash #set -x HEADER="--header=accept:image/webp,*/*;q=0.8 \ --header=accept-encoding:gzip,deflate,sdch \ --header=accept-language:cs-CZ,cs;q=0.8" UA="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" R="--referer=https://maps.google.com/" FCOOK="--cookies=on --keep-session-cookies --save-cookies=/tmp/testcookie.txt" SCOOK="--cookies=on --load-cookies=testcookie.txt --keep-session-cookies --save-cookies=/tmp/testcookie.txt" function logit() { echo `date "+%Y/%m/%d %H:%M:%S"` $@ } function init_down() { wget $HEADER -U "$UA" $FCOOK http://maps.google.com -O /tmp/firstout.html 2> /tmp/wget.out if [ $? != 0 ] then echo "Something wrong with wget, returned $?:" cat /tmp/wget.out exit 1 fi } function down_link() { wget $HEADER -U "$UA" $R $SCOOK $2 -O /tmp/$1 2> /tmp/wget.out if [ $? != 0 ] then echo "Something wrong with wget, returned $?:" cat /tmp/wget.out exit 1 fi } function down_square() { X=$1 Y=$2 logit "Downloading square ($X,$Y) files" xi=$X yi=$((131064-Y)) for i in `seq 0 7`; do for j in `seq 0 7`; do down_link g2xpl_8_17_${X}_${Y}-${xi}-${yi}.jpg "https://khms0.google.com/kh/v=145&src=app&x=$xi&y=$yi&z=17&s=Gali" xi=$((xi+1)) done xi=$X yi=$((yi+1)) done } function join_square() { X=$1 Y=$2 xi=$X yi=$((131064-Y)) logit "Merging square ($X,$Y) files" FL="" for i in `seq 0 7`; do for j in `seq 0 7`; do FL="$FL g2xpl_8_17_${X}_${Y}-${xi}-${yi}.jpg" xi=$((xi+1)) done xi=$X yi=$((yi+1)) done [ -e /tmp/gx2pl_finished ] || mkdir /tmp/gx2pl_finished montage -mode concatenate -tile 8x8 $FL /tmp/gx2pl_finished/g2xpl_8_17_${X}_${Y}.jpg if [ $? != 0 ] then echo "Something wrong with montage, returned $?:" exit 1 fi rm $FL } function usage() { echo "./script.sh [ ]" echo "X,Y dds zl17 coordinates" echo "X2,Y2 dds zl17 coordinates for range X,Y - X2,Y2" } if [ $# != 2 ] && [ $# != 4 ] then usage exit fi cd /tmp if [ $# == 2 ] then #init_down #down_square $1 $2 #join_square $1 $2 echo something fi if [ $# == 4 ] then for x in `seq $1 8 $3` do for y in `seq $2 8 $4` do init_down down_square $x $y join_square $x $y done done fi