From e33087894676bc013f3ea8e6ca16df11e1e63575 Mon Sep 17 00:00:00 2001 From: sasgis <> Date: Sat, 12 Dec 1970 12:00:00 +0000 Subject: [PATCH 1/2] update zmp --- Google/GoogleSat.zmp/GetUrlScript.txt | 75 +++++++++++++++++++++++++-- Google/GoogleSat.zmp/params.txt | 3 +- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/Google/GoogleSat.zmp/GetUrlScript.txt b/Google/GoogleSat.zmp/GetUrlScript.txt index 302526765..b036426f1 100644 --- a/Google/GoogleSat.zmp/GetUrlScript.txt +++ b/Google/GoogleSat.zmp/GetUrlScript.txt @@ -1,6 +1,73 @@ + +const + cErrorFlag = 'e'; + +function _RequestVersion(out AVersion: AnsiString): Boolean; +var + VCode: Cardinal; + VVer, VHeader, VData: AnsiString; +begin + Result := False; + AVersion := cErrorFlag; + if Assigned(Downloader) then begin + VCode := Downloader.DoHttpRequest( + 'https://maps.googleapis.com/maps/api/js', '', '', VHeader, VData + ); + if VCode = 200 then begin + VVer := RegExprGetMatchSubStr( + VData, 'https://khms\d+.googleapis\.com/kh\?v=(\d+)', 1 + ); + Result := VVer <> ''; + if Result then begin + AVersion := VVer; + end; + end else + if (VCode = 0) or (VCode >= 500) then begin + // internet connection or server error + AVersion := ''; + end else begin + // fatal request error + WriteLn(IntToStr(VCode)); + end; + end; +end; + +function _GetVersion(out AVersion: AnsiString): Boolean; +begin + if ScriptBuffer = '' then begin + Global.Lock; + try + if Global.Exists(0) then begin + ScriptBuffer := Global.GetVar(0); + if ScriptBuffer = '' then begin // this should never happen + ScriptBuffer := cErrorFlag; + end; + end else begin + if _RequestVersion(ScriptBuffer) then begin + Global.SetVar(0, ScriptBuffer); + end; + end; + finally + Global.Unlock; + end; + end; + + if (ScriptBuffer <> '') and (ScriptBuffer <> cErrorFlag) then begin + AVersion := ScriptBuffer; + end else begin + AVersion := Version; // fallback to the Version from Params.txt + end; + + Result := AVersion <> ''; +end; + var - khm: string; -begin - khm := RegExprReplaceMatchSubStr(GetURLBase, 'khms\.google', 'khms'+inttostr( Random(4) )+'.google' ); - ResultURL := khm + Version + '&src=app&x='+inttostr(GetX)+'&y='+inttostr(GetY)+'&z='+inttostr(GetZ-1)+'&s='+copy('Galileo',1, Random(8)); + VSatVer: AnsiString; +begin + if _GetVersion(VSatVer) then begin + ResultURL := Format( + 'https://khms%d.google.com/kh/v=%s&src=app&x=%d&y=%d&z=%d', + [Random(4), VSatVer, GetX, GetY, GetZ-1] + ); + end; end. diff --git a/Google/GoogleSat.zmp/params.txt b/Google/GoogleSat.zmp/params.txt index cf1412446..658cd891d 100644 --- a/Google/GoogleSat.zmp/params.txt +++ b/Google/GoogleSat.zmp/params.txt @@ -6,7 +6,6 @@ name_ru=Спутник (Google) name=Satellite (Google maps) name_uk=Супутник (Google) ParentSubMenu=Google -DefURLBase=http://khms.google.com/kh/v= projection=1 sradiusa=6378137 sradiusb=6378137 @@ -14,4 +13,4 @@ NameInCache=sat Ext=.jpg DefHotKey=71 ContentType=image/jpeg -Version=845 +IsUseDownloaderInScript=1 From 0d41954a278e09c647b18ba74374d358e62e4404 Mon Sep 17 00:00:00 2001 From: sasgis <> Date: Sat, 12 Dec 1970 12:00:00 +0000 Subject: [PATCH 2/2] update zmp --- Google/GoogleSat.zmp/GetUrlScript.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Google/GoogleSat.zmp/GetUrlScript.txt b/Google/GoogleSat.zmp/GetUrlScript.txt index b036426f1..c2f92cd3e 100644 --- a/Google/GoogleSat.zmp/GetUrlScript.txt +++ b/Google/GoogleSat.zmp/GetUrlScript.txt @@ -69,5 +69,10 @@ begin 'https://khms%d.google.com/kh/v=%s&src=app&x=%d&y=%d&z=%d', [Random(4), VSatVer, GetX, GetY, GetZ-1] ); + end else begin + ResultURL := Format( + 'https://mt%d.google.com/vt/lyrs=s&hl=%s&x=%d&y=%d&z=%d', + [Random(4), Lang, GetX, GetY, GetZ-1] + ); end; end.