Add option to allow adding duplicate notes
This commit is contained in:
parent
01e506588c
commit
36a55adf0a
@ -449,11 +449,21 @@ class AnkiConnect:
|
||||
if name in ankiNote:
|
||||
ankiNote[name] = value
|
||||
|
||||
allowDuplicate = False
|
||||
if 'options' in note:
|
||||
if 'allowDuplicate' in note['options']:
|
||||
allowDuplicate = note['options']['allowDuplicate']
|
||||
if type(allowDuplicate) is not bool:
|
||||
raise Exception('option parameter \'allowDuplicate\' must be boolean')
|
||||
|
||||
duplicateOrEmpty = ankiNote.dupeOrEmpty()
|
||||
if duplicateOrEmpty == 1:
|
||||
raise Exception('cannot create note because it is empty')
|
||||
elif duplicateOrEmpty == 2:
|
||||
if not allowDuplicate:
|
||||
raise Exception('cannot create note because it is a duplicate')
|
||||
else:
|
||||
return ankiNote
|
||||
elif duplicateOrEmpty == False:
|
||||
return ankiNote
|
||||
else:
|
||||
|
@ -685,7 +685,8 @@ guarantee that your application continues to function properly in the future.
|
||||
optional and can be omitted. If you choose to include it, the `url` and `filename` fields must be also defined. The
|
||||
`skipHash` field can be optionally provided to skip the inclusion of downloaded files with an MD5 hash that matches
|
||||
the provided value. This is useful for avoiding the saving of error pages and stub files. The `fields` member is a
|
||||
list of fields that should play audio when the card is displayed in Anki.
|
||||
list of fields that should play audio when the card is displayed in Anki. The 'allowDuplicate' member inside 'options'
|
||||
group can be set to true to enable adding duplicate cards. Normally duplicate cards can not be added and trigger exception.
|
||||
|
||||
*Sample request*:
|
||||
```json
|
||||
@ -700,6 +701,9 @@ guarantee that your application continues to function properly in the future.
|
||||
"Front": "front content",
|
||||
"Back": "back content"
|
||||
},
|
||||
"options": {
|
||||
"allowDuplicate": false
|
||||
},
|
||||
"tags": [
|
||||
"yomichan"
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user