lysrt/Anki.NET

Note Guid

Closed this issue · 2 comments

Hi! Thanks for the awesome library, I really needed your solution :)
I have a little change request: could you make the note guid editable?
https://github.com/lysrt/Anki.NET/blob/master/src/Anki.NET/AnkiFileWriter.cs#L222

I want to create a set and extend it over time but with every compile the notes are imported as new instead of marked as identical.

Thank you very much!

lysrt commented

Hi @SeriousM, thanks for this first issue!

Until I can fix this issue, I believe you can filter out duplicates in Anki like explained here.

Regarding the fix, the Guid guide page gives more information about how the Guid is used by Anki.

Initially I was thinking about updating the AnkiNote constructor (AnkiCollection.CreateNote()) so the Guid is editable, but the doc says that Anki creates its internal Guid.

I would like to ask how you use the lib.

  1. Do you create a new apkg file each time, and import a new apkg every time to Anki?
  2. Or do you read the previously generated apkg file, and add new notes to the existing AnkiCollection, before exporting it again?

Solution 1:
In the first case, I would consider updating AnkiNote constructor.

Solution 2:
In the second case, I need to fix Anki.NET to read the Guid of the notes in the existing file, instead of generating new notes on the fly when reading the file.

Notes:

  • The code used to write a new Guid when writing the apkg file is here, and I could update it to take this Guid from AnkiNote instead (solution 1).
  • The code to read an existing note Guid from the apkg file is here and I could use note.Guid when creating the existing AnkiNote (solution 2).

Hi Lucas!

I'm already waaay ahead of your implementation as you can see in this fork: https://github.com/SeriousM/Anki.NET
To the issue with the Guid: I tested the import and reimport of decks by declaring the guid myself and an "updated question" was signaled instead of a "new question".

Why do I needed that: I generate a anki set based on an external feed which gets updated periodically and I distributed the set to other people. To ensure they and I don't lose progress yet get new questions I needed to uniqify the questions but keep the possibility to extend it.

Thank you very much for your initial work, it helped me tremendously!