Import menu access from add-on

Hello,

I am want to port some code I wrote. Currently it take a specific file format and create a deck out of it.

I want to change this and just import the file into Anki via the import function of the main menu. Is there some way to access this functionality via a hook or something like this ?

That way, I won’t need to do some extra things, just plain import a file and let the magic operates.

Thanx

Anki doesn’t offer any such hook itself, but there is an add-on called Anki Connect that provides such features.

Got it but does not mean to do what I want. Thus, I will have to build a whole machinery.
Thnx

You can also use ki, which may be a bit more convoluted to use programmatically, but still better than nothing.

Clearly, your solutions are not what I want. As said, I already wrote a GUI app to build a deck from my file. What I want is just get rid of any external frontend/tool and build (or modify) a deck directly into Anki.

An add-on is the perfect way and correct way to achieve this. I thought I could just build something around the “import” feature. You proved me wrong, so I will do it integrally from my Anki add-on I am planning to write.

I would suggest simply adding another menu option to, as in File → Import from YAML or something. You cold “manually” hook into the importing machinery—this is Python after all—but that’s fragile and can break with Anki update, and can break not only the add-on functionality but also Anki itself.

Also personally I just like it when add-ons add new menu items or buttons. Kinda weird when you install a thing and it appears nowhere.

3 Likes

Good idea. Just need to understand how to do this :slight_smile: