-
Notifications
You must be signed in to change notification settings - Fork 221
Can't prevent duplicates from being added via API #164
Comments
The duplicateScope option should not be the deck name; it should be the literal word "deck" (as opposed to "global"). |
Got it, I'll give that a shot thanks! |
Updated the duplicateScope option to "deck" but I'm still able to create duplicates any thing else I should try? |
We cannot know what the various class attributes contain, or what gets done with that afterwards. So instead of showing us your code, show the actual JSON that is finally sent to AnkiConnect. Even better, enable AnkiConnect's log file, run that note through twice to create the duplicate, and then show the log file which proves that you have identical JSON appearing twice and returning two resulting note IDs instead of an error. |
Here is the JSON I'm sending an the result I'm getting. Happy to send over the AnkiConnect's log file, but not sure how to enable it (couldn't find in the documentation). Card 1 JSON{'deckName': 'default', 'modelName': 'Basic', 'fields': {'Front': ' What is the correlation between market & GDP?\n', 'Back': 'The correlation between the growth of GDP and the growth of corporate profits is 0.98. (1.0 is perfect.) I assume that this long-term relationship will prevail in the years ahead.\n'}, 'options': {'allowDuplicate': False, 'duplicateScope': 'deck'}, 'tags': [' The Little Book of Common Sense Investing by John C. Bogle\n', 'Investing', 'Index Funds', 'John C. Bogle']} Card 1 Response1588934391594 Card 2 JSON{'deckName': 'default', 'modelName': 'Basic', 'fields': {'Front': ' What is the correlation between market & GDP?\n', 'Back': 'The correlation between the growth of GDP and the growth of corporate profits is 0.98. (1.0 is perfect.) I assume that this long-term relationship will prevail in the years ahead.\n'}, 'options': {'allowDuplicate': False, 'duplicateScope': 'deck'}, 'tags': [' The Little Book of Common Sense Investing by John C. Bogle\n', 'Investing', 'Index Funds', 'John C. Bogle']} Card 2 Response1588934391620 |
In Anki, Tools->Add-ons, choose AnkiConnect and hit Config.
"apiLogPath": "path/to/a/file",
Then restart Anki.
To be strictly technical, what you've shown here is not JSON (you can tell because it uses single quotes and a capitalized False; JSON requires double quotes and lower case false). This is still your Python dictionary, therefore must be going through some translation before being sent to AnkiConnect.
However, I'm able to repeat the behavior with this note! It appears to be related to the whitespace - when I remove both the space before ' What' and the trailing '\n', I get the expected behavior.
|
First - THANKS so much for creating this API, it's been a lifesaver for me as I try to turn my kindle highlights into anki cards.
One issue I'm having is the ability to prevent duplicate cards from being created. I've set the flag to 'False' but it still allows me to create a duplicate cards.
Here's an example of the JSON object I'm passing through -> https://github.com/matthewwoo/kindle_anki/blob/master/models.py
The text was updated successfully, but these errors were encountered: