Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DedInc committed Apr 29, 2023
1 parent a681c47 commit ecc1d6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
32 changes: 14 additions & 18 deletions iphub/iphub.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,31 @@ def _get_session(self):
def get_keys(self):
keys = []
r = self.session.get('https://iphub.info/account')
self.ctoken = r.text.split('token" content="')[1].split('"')[0]
dem = r.text.split('/apiKey/')
for line in dem:
try:
if dem.index(line) != 0:
keys.append(line.split('"')[0])
keys.append(line.split('"')[0])
except:
self.regenerate_key()
return self.get_keys()
return keys
pass
if len(keys) == 0:
self.generate_key()
return self.get_keys()
return keys

def get_key(self, id):
try:
return 'MT' + self.session.get(f'https://iphub.info/apiKey/{id}').text.split('"MT')[1].split('"')[0]
except:
return None
return self.session.get(f'https://iphub.info/apiKey/{id}').text.split('readonly value="')[1].split('"')[0]

def regenerate_key(self, id):
try:
self.session.post(f'https://iphub.info/apiKey/regenerateApiKey/{id}', data={'_token': self.ctoken})
return self.get_key(id)
except:
return None
r = self.session.post(f'https://iphub.info/apiKey/regenerateApiKey/{id}', data={'_token': self.ctoken})
self.ctoken = r.text.split('token" content="')[1].split('"')[0]
return self.get_key(id)

def generate_key(self):
try:
self.session.post('https://iphub.info/apiKey/newFree', data={'_token': self.ctoken})
return self.get_key(self.get_keys()[0])
except:
return None
r = self.session.post('https://iphub.info/apiKey/newFree', data={'_token': self.ctoken})
self.ctoken = r.text.split('token" content="')[1].split('"')[0]
return self.get_key(self.get_keys()[0])

def check_ip(self, ip):
r = get(url=f'http://v2.api.iphub.info/ip/{ip}', headers={'X-Key': self.api_key}).json()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='iphub',
version='1.0.1',
version='1.0.2',
author='Maehdakvan',
author_email='visitanimation@google.com',
description='IPhub.info API wrapper.',
Expand Down

0 comments on commit ecc1d6b

Please sign in to comment.