Merge pull request #33 from techdavid/decknamesandids

Add deckNamesAndIds action
This commit is contained in:
Alex Yatskov 2017-08-16 17:27:13 -07:00 committed by GitHub
commit 6399da13e7
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.