Add cardsToNotes function

This commit is contained in:
David Bailey 2017-08-09 19:05:00 +01:00
parent 6a6f9d7d2a
commit e02f8b2d65
2 changed files with 32 additions and 0 deletions

View File

@ -507,6 +507,10 @@ class AnkiBridge:
return [] return []
def cardsToNotes(self, cards):
return self.window().col.db.list('select distinct nid from cards where id in ' + anki.utils.ids2str(cards))
def guiBrowse(self, query=None): def guiBrowse(self, query=None):
browser = aqt.dialogs.open('Browser', self.window()) browser = aqt.dialogs.open('Browser', self.window())
browser.activateWindow() browser.activateWindow()
@ -781,6 +785,11 @@ class AnkiConnect:
return self.anki.findCards(query) return self.anki.findCards(query)
@webApi
def cardsToNotes(self, cards):
return self.anki.cardsToNotes(cards)
@webApi @webApi
def guiBrowse(self, query=None): def guiBrowse(self, query=None):
return self.anki.guiBrowse(query) return self.anki.guiBrowse(query)

View File

@ -490,6 +490,29 @@ Below is a list of currently supported actions. Requests with invalid actions or
] ]
``` ```
* **cardsToNotes**
Returns an (unordered) array of note IDs for the given card IDs. For cards with the same note, the ID is only
given once in the array.
*Sample request*:
```
{
"action": "cardsToNotes",
"params": {
"cards": [1502098034045, 1502098034048, 1502298033753]
}
}
```
*Sample response*:
```
[
1502098029797,
1502298025183
]
```
* **guiBrowse** * **guiBrowse**
Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found. Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found.