It is currently September 19th, 2020, 10:12 am

Trying to run AnkiConnect with Rainmeter

Discuss the use of Lua in Script measures.
User avatar
imaquietkid
Posts: 5
Joined: February 13th, 2020, 3:54 pm

Trying to run AnkiConnect with Rainmeter

Post by imaquietkid »

I am trying to make a skin that would connect with Anki and display how many cards are due at a given moment. Maybe even (if I can) have a way to add cards directly from the desktop. From what I understand it should be possible with AnkiConnect (website here). The AnkiConnect website gives some example code in Python and JavaScript, so I guess my job is to translate that into lua but I'm kinda out of my depths here.

There are these two lines of Python code that I just straight up don't understand :

Code: Select all

    requestJson = json.dumps(request(action, **params)).encode('utf-8')
    response = json.load(urllib.request.urlopen(urllib.request.Request('http://localhost:8765', requestJson)))
I also think I need to import a JSON module to be able to use the API, and I'm not sure how to do that with Rainmeter.

Any help would be massively appreciated, thanks in advance.
User avatar
LGP123
Posts: 60
Joined: November 5th, 2016, 12:15 pm

Re: Trying to run AnkiConnect with Rainmeter

Post by LGP123 »

I don't think there are ways to use APIs directly in Rainmeter without using external program, but you could for example add in your @Resource folder a small python program ran by rainmeter that could call Anki's API (for compatibility purpose, you should also include a python instance in the skin files).
User avatar
imaquietkid
Posts: 5
Joined: February 13th, 2020, 3:54 pm

Re: Trying to run AnkiConnect with Rainmeter

Post by imaquietkid »

I see, fair enough, I didn't even think of using Python directly, but I can manage that. Thank you!