Add tagging and suspend functions
This commit is contained in:
parent
5dfffadda7
commit
e8088146f3
@ -375,6 +375,20 @@ class AnkiBridge:
|
|||||||
return note
|
return note
|
||||||
|
|
||||||
|
|
||||||
|
def addTags(self, query, tags, add=True):
|
||||||
|
notes = aqt.mw.col.findNotes(query)
|
||||||
|
aqt.mw.col.tags.bulkAdd(notes, tags, add)
|
||||||
|
|
||||||
|
|
||||||
|
def suspend(self, query, suspend=True):
|
||||||
|
cards = aqt.mw.col.findCards(query)
|
||||||
|
if suspend:
|
||||||
|
suspendFunction = aqt.mw.col.sched.suspendCards
|
||||||
|
else:
|
||||||
|
suspendFunction = aqt.mw.col.sched.unsuspendCards
|
||||||
|
suspendFunction(cards)
|
||||||
|
|
||||||
|
|
||||||
def startEditing(self):
|
def startEditing(self):
|
||||||
self.window().requireReset()
|
self.window().requireReset()
|
||||||
|
|
||||||
@ -662,6 +676,26 @@ class AnkiConnect:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
@webApi
|
||||||
|
def addTags(self, query, tags, add=True):
|
||||||
|
return self.anki.addTags(query, tags, add)
|
||||||
|
|
||||||
|
|
||||||
|
@webApi
|
||||||
|
def removeTags(self, query, tags):
|
||||||
|
return self.anki.addTags(query, tags, False)
|
||||||
|
|
||||||
|
|
||||||
|
@webApi
|
||||||
|
def suspend(self, query, suspend=True):
|
||||||
|
return self.anki.suspend(query, suspend)
|
||||||
|
|
||||||
|
|
||||||
|
@webApi
|
||||||
|
def unsuspend(self, query):
|
||||||
|
return self.anki.suspend(query, False)
|
||||||
|
|
||||||
|
|
||||||
@webApi
|
@webApi
|
||||||
def upgrade(self):
|
def upgrade(self):
|
||||||
response = QMessageBox.question(
|
response = QMessageBox.question(
|
||||||
|
78
README.md
78
README.md
@ -305,6 +305,84 @@ Below is a list of currently supported actions. Requests with invalid actions or
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* **addTags**
|
||||||
|
|
||||||
|
Adds tags to notes matching a query (same syntax as **browse**/**guiBrowse**).
|
||||||
|
|
||||||
|
*Sample request*:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"action": "addTags",
|
||||||
|
"params": {
|
||||||
|
"query": "deck:French or deck:Spanish",
|
||||||
|
"tags": "european-languages"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Sample response*:
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
* **removeTags**
|
||||||
|
|
||||||
|
Remove tags from notes matching a query (same syntax as **browse**/**guiBrowse**).
|
||||||
|
|
||||||
|
*Sample request*:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"action": "removeTags",
|
||||||
|
"params": {
|
||||||
|
"query": "deck:Japanese or deck:Chinese",
|
||||||
|
"tags": "european-languages"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Sample response*:
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
* **suspend**
|
||||||
|
|
||||||
|
Suspend cards matching a query (same syntax as **browse**/**guiBrowse**).
|
||||||
|
|
||||||
|
*Sample request*:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"action": "suspend",
|
||||||
|
"params": {
|
||||||
|
"query": "tag:difficult"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Sample response*:
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
* **unsuspend**
|
||||||
|
|
||||||
|
Unsuspend cards matching a query (same syntax as **browse**/**guiBrowse**).
|
||||||
|
|
||||||
|
*Sample request*:
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"action": "unsuspend",
|
||||||
|
"params": {
|
||||||
|
"query": "tag:easy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Sample response*:
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
* **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.
|
||||||
|
Loading…
Reference in New Issue
Block a user