Add deckNamesAndIds action

This commit is contained in:
David Bailey 2017-08-16 22:26:53 +01:00
parent c0a04c6815
commit b8c5b7c980
2 changed files with 34 additions and 0 deletions

View File

@ -515,6 +515,17 @@ class AnkiBridge:
return collection.decks.allNames()
def deckNamesAndIds(self):
decks = {}
deckNames = self.deckNames()
for deck in deckNames:
id = self.collection().decks.id(deck)
decks[deck] = id
return decks
def deckNameFromId(self, deckId):
collection = self.collection()
if collection is not None:
@ -753,6 +764,11 @@ class AnkiConnect:
return self.anki.deckNames()
@webApi
def deckNamesAndIds(self):
return self.anki.deckNamesAndIds()
@webApi
def modelNames(self):
return self.anki.modelNames()

View File

@ -121,6 +121,24 @@ Below is a list of currently supported actions. Requests with invalid actions or
]
```
* **deckNamesAndIds**
Gets the complete list of deck names and their respective IDs for the current user.
*Sample request*:
```
{
"action": "deckNamesAndIds"
}
```
*Sample response*:
```
{
"Default": 1
}
```
* **modelNames**
Gets the complete list of model names for the current user.