forked from encode32/PokeVisionFinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPokeVisionFinder.py
156 lines (129 loc) · 4.13 KB
/
PokeVisionFinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import os
from sys import argv
import urllib2
from time import sleep,time
import json
from pokemons import pokemonlist
__author__ = 'encode'
_delay = 5 #seconds
_useMode = "Skip" #Skip,Go
_logging = True
_zoomFactor = 1 #1 = 0.05 = 13.85Km
_nonstop = True
_cities = []
_pokemons = []
#Clear
def _clear():
#windows
os.system('cls')
#linux
#os.system('clear')
#Sleep
def _sleep():
sleep(_delay)
#JsonData
def _jsondata(url):
_rawdata = urllib2.urlopen(url)
return json.load(_rawdata)
#JsonData Custom Headers
def _jsondatach(url):
_headers = { 'User-Agent' : 'Mozilla/5.0' }
_req = urllib2.Request(url, None,_headers)
_rawdata = urllib2.urlopen(_req)
return json.load(_rawdata)
#Pokemon Name
def _pokename(id):
return pokemonlist[id-1]
def _pokesplit(pokemons):
global _pokemons
_pokemons = pokemons.split(",")
#POkePrinter
def _printer(name,lat,lng,exp):
_time = time()
_remain = exp-time()
_minutes = int(_remain / 60)
_seconds = int(_remain % 60)
_expire = str(_minutes) + " Minutes, " + str(_seconds) + " Seconds"
print "-------------------------------------------------"
print "Pokemon: " + name
print "Coordinates: " + str(lat) + "," + str(lng)
print "Expires in: " + _expire
print "-------------------------------------------------"
_logPokemon(name, str(lat), str(lng), _expire)
#CoordsLoader
def _populateCities():
with open("coords.txt", "a+") as f:
_data = f.readlines()
for line in _data:
_citydata = line.split(":")
_cities.append([_citydata[0],_citydata[1],_citydata[2]])
f.close()
#Logger
def _logPokemon(name, lat, lng, expire):
with open("pokemons.log", "a+") as f:
f.write("[" + name + "] [" + lat + "," + lng + "] [" + expire + "]\n")
f.close()
#Finder
def _finderSkipLagged(city):
print "[INFO] Looking pokemons in: " + city[0]
_latitudesw = float(city[1]) - (0.05 * _zoomFactor)
_longitudesw = float(city[2]) - (0.05 * _zoomFactor)
_latitudene = float(city[1]) + (0.05 * _zoomFactor)
_longitudene = float(city[2]) + (0.05 * _zoomFactor)
_scanurl = "https://skiplagged.com/api/pokemon.php?bounds="+str(_latitudesw)+","+str(_longitudesw)+\
","+str(_latitudene)+","+str(_longitudene)
_scanurljsondata = _jsondatach(_scanurl)
for pokename in _pokemons:
for pokemon in _scanurljsondata['pokemons']:
_id = pokemon['pokemon_id']
_name = _pokename(_id)
if pokename.lower() in _name.lower():
_lat = pokemon['latitude']
_lng = pokemon['longitude']
_exp = pokemon['expires']
_printer(_name, _lat, _lng, _exp)
#Finder
def _finderGo(city):
print "[INFO] Looking pokemons in: " + city
_latitudesw = float(city[1]) - (0.05 * _zoomFactor)
_longitudesw = float(city[1]) - (0.05 * _zoomFactor)
_latitudene = float(city[2]) + (0.05 * _zoomFactor)
_longitudene = float(city[2]) + (0.05 * _zoomFactor)
_scanurl = "https://api-live-us1.pokemongo.id/maps?vt=-"+str(_latitudesw)+","+str(_longitudesw)+\
","+str(_latitudene)+","+str(_longitudene)+"&u="+str(time())
_scanurljsondata = _jsondatach(_scanurl)
for pokename in _pokemons:
for pokemon in _scanurljsondata['pokemons']:
_id = pokemon['pokemon_id']
_name = _pokename(_id)
if pokename.lower() in _name.lower():
_lat = pokemon['latitude']
_lng = pokemon['longitude']
_exp = pokemon['expires']
_printer(_name, _lat, _lng, _exp)
#Loop
def _loop():
for city in _cities:
if "Skip" in _useMode:
_finderSkipLagged(city)
elif "Go" in _useMode:
_finderGo(city)
#Init
_inputpoke = ""
_populateCities()
if len(argv) == 2:
_inputpoke = argv[1]
elif len(argv) == 5:
_inputpoke = argv[1]
_nonstop = int(argv[2]) == 1
_zoomFactor = float(argv[3])
_logging = int(argv[4]) == 1
else:
_inputpoke = raw_input("Pokemon: ")
_pokesplit(_inputpoke)
if _nonstop:
while 1:
_loop()
_sleep()
else:
_loop()