Automatically open WaniKani when it's review time

Here you go :slight_smile:

from urllib.request import urlopen
import json
import time
import webbrowser

api_key = "YOUR_API_KEY"

data = json.load(urlopen("http://www.wanikani.com/api/user/%s/study-queue" % api_key))
seconds_til_review = data["requested_information"]["next_review_date"]-int(time.time())
hours_til_review = round(seconds_til_review/60/60, 2)

if hours_til_review < 0.15:
  webbrowser.get("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe --new-window %s").open("https://www.wanikani.com/review")
else:
  print("Hours til review: %s" % hours_til_review)
  time.sleep(10)

And here’s some instructions.

1) Install Python 3

Download it from here: https://www.python.org/downloads/

2) Create the code file

Open up Notepad or your favorite code editor. Copy and paste that code section above. Replace the “YOUR_API_KEY” text with your API key from here.

Save this file somewhere where you can find it, and make sure to name it with a .py file extension. If you’re using notepad, you’ll need to change the “Save as type” to “All Files (*.*)” like in this image.

image

To test if it works, just double-click on the .py file.

3) Create a scheduled task

Follow the step 3 from the original post above, except when instead of typing C:\php\php.exe for the “Program/script”, just browse to your .py file. And also, do not type anything for “Add arguments”.

4) Burn some turtles

:wink:

3 Likes