FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.92k stars 218 forks source link

add a new action: getMediaDirPath #379

Closed tatsumoto-ren closed 1 year ago

tatsumoto-ren commented 1 year ago

This PR adds the getMediaDirPath action that returns the full path to the user's collection folder.

Currently Mpvacious has to rely on the storeMediaFile action to add new audio and images to the collection, but this proves to be problematic. When called with base64-encoded data, it may fail if the file is too big, and when called with a path to a temporary file, it may fail because Anki doesn't have access to the folder where the file is stored.

With this function we would be able to send files directly to the collection.media folder without encoding them as base64 or using temporary files.

FooSoft commented 1 year ago

Looks good, could you just add a simple test case for calling this API and making sure it doesn't fail?

tatsumoto-ren commented 1 year ago

I can try. This repo doesn't include any docs on how to create and run tests, I'll try inferring that from the source code.

Seems like I need a program called tox, never heard of it.

FooSoft commented 1 year ago

Thanks!

tatsumoto-ren commented 1 year ago

The extension on AnkiWeb hasn't been updated yet. It would be awesome if you uploaded a new version 🙏.