anki-connect icon indicating copy to clipboard operation
anki-connect copied to clipboard

Add an option to update notes in addNote

Open gsingh93 opened this issue 4 years ago • 1 comments

I've been using Anki's built-in TextImporter with CSV files, and the functionality there is that if the first field of a note (i.e. 'Front') matches an existing note, then instead of adding a duplicate card or not adding it at all, it updates the other fields to the new values.

Achieving this with AnkiConnect is a bit more painful, it seems like I'll have to first call canAddNotes, call addNotes with the ones that return true, get the indices of the notes that weren't added, use a findNotes query to find the IDs of those notes, and then call updateNoteFields with those IDs. I just started going through the API today, so let me know if there's a better way to do this.

Ideally, it would be nice if there was an option like updateDuplicateNotes I could pass in instead of going through all this.

gsingh93 avatar May 31 '20 21:05 gsingh93

If anyone else needs to do this, you can see how I did it here: https://github.com/gsingh93/anki-csv-importer/blob/b7c1fd747ac7e39bd8a601d3a23f324b508a59c3/anki-csv-importer.py#L43

I used multi to make it efficient, but it's quite a PITA to have to write all this. Would be great to have this built into AnkiConnect.

gsingh93 avatar Jun 07 '20 01:06 gsingh93