~foosoft/anki-connect

30f3d5618a6347948b21b629e06537b43aa121d2 — David Bailey 7 years ago a78d404
Rename browse to findCards and add new findNotes function

2 files changed, 52 insertions(+), 17 deletions(-)

M AnkiConnect.py
M README.md
M AnkiConnect.py => AnkiConnect.py +23 -11
@@ 460,6 460,20 @@ class AnkiBridge:
                return deck['name']


    def findNotes(self, query=None):
        if query is not None:
            return aqt.mw.col.findNotes(query)
        else:
            return []


    def findCards(self, query=None):
        if query is not None:
            return aqt.mw.col.findCards(query)
        else:
            return []


    def guiBrowse(self, query=None):
        browser = aqt.dialogs.open('Browser', self.window())
        browser.activateWindow()


@@ 474,13 488,6 @@ class AnkiBridge:
        return browser.model.cards


    def browse(self, query=None):
        if query is not None:
            return aqt.mw.col.findCards(query)
        else:
            return []


    def guiAddCards(self):
        addCards = aqt.dialogs.open('AddCards', self.window())
        addCards.activateWindow()


@@ 722,13 729,18 @@ class AnkiConnect:


    @webApi
    def guiBrowse(self, query=None):
        return self.anki.guiBrowse(query)
    def findNotes(self, query=None):
        return self.anki.findNotes(query)


    @webApi
    def findCards(self, query=None):
        return self.anki.findCards(query)


    @webApi
    def browse(self, query=None):
        return self.anki.browse(query)
    def guiBrowse(self, query=None):
        return self.anki.guiBrowse(query)


    @webApi

M README.md => README.md +29 -6
@@ 383,14 383,37 @@ Below is a list of currently supported actions. Requests with invalid actions or
    null
    ```

*   **guiBrowse**
*   **findNotes**

    Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found.
    Returns an array of note IDs for a given query (same query syntax as **guiBrowse**).

    *Sample request*:
    ```
    {
        "action": "guiBrowse",
        "action": "findCards",
        "params": {
            "query": "deck:current"
        }
    }
    ```

    *Sample response*:
    ```
    [
        1483959289817,
        1483959291695
    ]
    ```

*   **findCards**

    Returns an array of card IDs for a given query (functionally identical to **guiBrowse** but doesn't use the GUI
    for better performance).

    *Sample request*:
    ```
    {
        "action": "findCards",
        "params": {
            "query": "deck:current"
        }


@@ 406,14 429,14 @@ Below is a list of currently supported actions. Requests with invalid actions or
    ]
    ```

*   **browse**
*   **guiBrowse**

    Functionally identical to **guiBrowse**, but accesses the database without using the GUI for increased performance.
    Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found.

    *Sample request*:
    ```
    {
        "action": "browse",
        "action": "guiBrowse",
        "params": {
            "query": "deck:current"
        }

Do not follow this link