Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for pokesnipers.com api data #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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