Created
August 3, 2018 03:21
-
-
Save AlexCMueller/7ab0fb99a01e1b98cf0c6e7a9da15d6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import authinfo | |
import json | |
import requests | |
import time | |
jar = requests.cookies.RequestsCookieJar() | |
jar.set('iksm_session', authinfo.cookie) | |
base_url = "https://app.splatoon2.nintendo.net" | |
shop_url = base_url + "/api/onlineshop/merchandises" | |
hook_url = authinfo.hook_url | |
while True: | |
r = requests.get(shop_url, cookies=jar) | |
response = json.loads(r.text) | |
if not response["merchandises"]: | |
print("Bad response: %s"%(r.text)) | |
else: | |
gear = response["merchandises"][-1] | |
name = gear["gear"]["name"] | |
ability = gear["skill"]["name"] | |
brand = gear["gear"]["brand"] | |
brand_name = brand["name"] | |
brand_icon = base_url + brand["image"] | |
gear_image = base_url + gear["gear"]["image"] | |
embed = { | |
"title": "%s with %s"%(name, ability), | |
"author": { | |
"name": brand_name, | |
"icon_url": brand_icon | |
}, | |
"image": { | |
"url": gear_image | |
} | |
} | |
payload = {"embeds": [embed]} | |
postres = requests.post(hook_url, json=payload) | |
current_time = time.time() | |
update_time = response["merchandises"][0]["end_time"]+5 | |
time.sleep(update_time-current_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment