summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-02-25 13:43:39 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-02-25 13:43:39 +0100
commit1c550fdc51d16ec15c39edb346c28d5f07a2a425 (patch)
tree1f1aa46ae5eb69e3fb146f64cbc29acee4b6fb7a
parent6de987c9cb845bdf164fbb344d98448f5dc05899 (diff)
downloadapigrabber-1c550fdc51d16ec15c39edb346c28d5f07a2a425.tar.gz
apigrabber-1c550fdc51d16ec15c39edb346c28d5f07a2a425.zip
add VAINSOCIAL_APIKEY env variable
-rw-r--r--api.py7
-rw-r--r--crawler.py5
2 files changed, 7 insertions, 5 deletions
diff --git a/api.py b/api.py
index 1cfa918..89573ce 100644
--- a/api.py
+++ b/api.py
@@ -28,7 +28,9 @@ def iso2date(d):
class Apigrabber(object):
- def __init__(self, regions, first_fetch=None, last_fetch=None):
+ def __init__(self, regions, apitoken,
+ first_fetch=None, last_fetch=None):
+ self._apitoken = apitoken
self.update_live = False
# TODO refactor this
if first_fetch is None:
@@ -138,7 +140,7 @@ class Apigrabber(object):
async def crawl_timeframe(self, region, jobid, jobstart, jobend):
"""Crawl a time frame forwards from `date` in `region`."""
async with self._pool.acquire() as con:
- api = crawler.Crawler()
+ api = crawler.Crawler(self._apitoken)
async with con.transaction():
params = {
"filter[createdAt-start]": date2iso(jobstart),
@@ -267,6 +269,7 @@ class Apigrabber(object):
async def startup():
apigrabber = Apigrabber(
+ apitoken=os.environ["VAINSOCIAL_APITOKEN"],
regions=os.environ["VAINSOCIAL_REGIONS"].split(","),
first_fetch=os.environ.get("VAINSOCIAL_STARTDATE"),
last_fetch=os.environ.get("VAINSOCIAL_ENDDATE")
diff --git a/crawler.py b/crawler.py
index 7ceda92..b68ec22 100644
--- a/crawler.py
+++ b/crawler.py
@@ -4,15 +4,14 @@ import asyncio
import logging
import aiohttp
-TOKEN = "aaa.bbb.ccc"
APIURL = "https://api.dc01.gamelockerapp.com/"
class Crawler(object):
- def __init__(self):
+ def __init__(self, token):
"""Sets constants."""
self._apiurl = APIURL
- self._token = TOKEN
+ self._token = token
self._pagelimit = 50
async def _req(self, session, path, params=None):