Return reason note cannot be added in new api endpoint
This commit is contained in:
parent
2f7bc2e78e
commit
bbf271c5ac
64
README.md
64
README.md
@ -3698,6 +3698,70 @@ Search parameters are passed to Anki, check the docs for more information: https
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
#### `canAddNotesWithErrorDetail`
|
||||||
|
|
||||||
|
* Accepts an array of objects which define parameters for candidate notes (see `addNote`) and returns an array of
|
||||||
|
objects with fields `canAdd` and `error`.
|
||||||
|
|
||||||
|
* `canAdd` indicates whether or not the parameters at the corresponding index could be used to create a new note.
|
||||||
|
* `error` contains an explanation of why a note cannot be added.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><i>Sample request:</i></summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"action": "canAddNotesWithErrorDetail",
|
||||||
|
"version": 6,
|
||||||
|
"params": {
|
||||||
|
"notes": [
|
||||||
|
{
|
||||||
|
"deckName": "Default",
|
||||||
|
"modelName": "Basic",
|
||||||
|
"fields": {
|
||||||
|
"Front": "front content",
|
||||||
|
"Back": "back content"
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"yomichan"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"deckName": "Default",
|
||||||
|
"modelName": "Basic",
|
||||||
|
"fields": {
|
||||||
|
"Front": "front content 2",
|
||||||
|
"Back": "back content 2"
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"yomichan"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><i>Sample result:</i></summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
canAdd: false,
|
||||||
|
error: 'cannot create note because it is a duplicate'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
canAdd: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"error": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
#### `updateNoteFields`
|
#### `updateNoteFields`
|
||||||
|
|
||||||
* Modify the fields of an existing note. You can also include audio, video, or picture files which will be added to the note with an
|
* Modify the fields of an existing note. You can also include audio, video, or picture files which will be added to the note with an
|
||||||
|
@ -788,6 +788,17 @@ class AnkiConnect:
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@util.api()
|
||||||
|
def canAddNoteWithErrorDetail(self, note):
|
||||||
|
try:
|
||||||
|
return {
|
||||||
|
'canAdd': bool(self.createNote(note))
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
'canAdd': False,
|
||||||
|
'error': str(e)
|
||||||
|
}
|
||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
def updateNoteFields(self, note):
|
def updateNoteFields(self, note):
|
||||||
@ -1959,6 +1970,14 @@ class AnkiConnect:
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@util.api()
|
||||||
|
def canAddNotesWithErrorDetail(self, notes):
|
||||||
|
results = []
|
||||||
|
for note in notes:
|
||||||
|
results.append(self.canAddNoteWithErrorDetail(note))
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
def exportPackage(self, deck, path, includeSched=False):
|
def exportPackage(self, deck, path, includeSched=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user