Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pgoapi/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import time
import struct
import logging
import requests

from json import JSONEncoder

Expand Down Expand Up @@ -98,3 +99,23 @@ def get_format_time_diff(low, high, ms = True):
h, m = divmod(m, 60)

return (h, m, s)

# An object containing the API data from pokesnipers.com
class Snipes(object):
def __init__(self, requestJson):
self.snipes = []

for pokemon in requestJson["results"]:
pokedict = {}
pokedict["name"] = pokemon["name"]
pokedict["coordinates"] = pokemon["coords"]
pokedict["until"] = pokemon["until"]
pokedict["icon"] = pokemon["icon"]
# Didn't put in IVs ... it usually returns 0 when not known (which is a majority of the time)
self.snipes.append(pokedict)

# Get the most recent snipes
def getSnipes():
requestJson = requests.get("http://www.pokesnipers.com/api/v1/pokemon.json").json()
snipesObj = Snipes(requestJson)
return snipesObj