Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
Update to a far faster, more accurate, and bug-free API.
This will likely be the last update for a while to this program unless anything breaks.
It is very consistent and should be used instead of 1.0.0.
  • Loading branch information
Shinryin authored Apr 9, 2023
1 parent 354eb33 commit f51720e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ip2time.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@
}

def get_external_ip():
response = requests.get("https://api.ipify.org?format=json")
return response.json()['ip']
response = requests.get("http://ip-api.com/json/")
return response.json()['query']

def get_timezone(ip):
while True:
try:
response = requests.get(f"https://ipapi.co/{ip}/json/", timeout=5)
response = requests.get(f"http://ip-api.com/json/{ip}", timeout=5)
data = response.json()
timezone = data['timezone']
location = (data['city'], data['region'], data['country'])
location = (data['city'], data['regionName'], data['country'])
return (timezone, location)
except Exception as e:
print(f"Error getting timezone: {e}")
Expand Down Expand Up @@ -172,5 +172,5 @@ def main():

if __name__ == "__main__":
main()

input("Press enter to close...")

0 comments on commit f51720e

Please sign in to comment.