Expanding API
This commit is contained in:
parent
d2bdda937a
commit
60f85a962c
@ -35,6 +35,7 @@ class AnkiConnect:
|
||||
self.handlers = {
|
||||
'addNote': self.apiAddNote,
|
||||
'apiCanAddNote': self.apiCanAddNote,
|
||||
'apiCanAddNotes': self.apiCanAddNotes,
|
||||
'getVersion': self.apiGetVersion,
|
||||
}
|
||||
|
||||
@ -105,6 +106,22 @@ class AnkiConnect:
|
||||
return self.anki.canAddNote(params['deck'], params['model'], params['fields'])
|
||||
|
||||
|
||||
def apiCanAddNotes(self, data):
|
||||
definitions = data.get('definitions', [])
|
||||
|
||||
for definition in definitions:
|
||||
definitions['anki'] = results = {}
|
||||
for mode in ['vocabExp', 'vocabReading', 'kanji']:
|
||||
params = self.prepareNoteParams(definition, mode)
|
||||
results[mode] = params is not None and self.anki.canAddNote(
|
||||
params['deck'],
|
||||
params['model'],
|
||||
params['fields']
|
||||
)
|
||||
|
||||
return definitions
|
||||
|
||||
|
||||
def apiGetVersion(self, data):
|
||||
return {'version': constants.c['appVersion']}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user