added method to retrieve the active profile

This commit is contained in:
Diogo Cadavez 2024-07-02 15:27:19 +02:00 committed by Alex Yatskov
parent 81c39a2e42
commit 0514569621
2 changed files with 36 additions and 3 deletions

View File

@ -2132,6 +2132,33 @@ Search parameters are passed to Anki, check the docs for more information: https
``` ```
</details> </details>
#### `getActiveProfile`
* Retrieve the active profile.
<details>
<summary><i>Sample request:</i></summary>
```json
{
"action": "getActiveProfile",
"version": 6
}
```
</details>
<details>
<summary><i>Sample result:</i></summary>
```json
{
"result": "User 1",
"error": null
}
```
</details>
#### `loadProfile` #### `loadProfile`
* Selects the profile specified in request. * Selects the profile specified in request.
@ -4147,8 +4174,8 @@ Search parameters are passed to Anki, check the docs for more information: https
#### `notesInfo` #### `notesInfo`
* Returns a list of objects containing for each note ID the note fields, tags, note type, modification time and the cards belonging to * Returns a list of objects containing for each note ID the note fields, tags, note type, modification time,the cards belonging to
the note. the note and the profile where the note was created.
<details> <details>
<summary><i>Sample request:</i></summary> <summary><i>Sample request:</i></summary>
@ -4172,6 +4199,7 @@ Search parameters are passed to Anki, check the docs for more information: https
"result": [ "result": [
{ {
"noteId":1502298033753, "noteId":1502298033753,
"profile": "User_1",
"modelName": "Basic", "modelName": "Basic",
"tags":["tag","another_tag"], "tags":["tag","another_tag"],
"fields": { "fields": {
@ -4179,6 +4207,7 @@ Search parameters are passed to Anki, check the docs for more information: https
"Back": {"value": "back content", "order": 1} "Back": {"value": "back content", "order": 1}
}, },
"mod": 1718377864, "mod": 1718377864,
"cards": [1498938915662]
} }
], ],
"error": null "error": null

View File

@ -456,7 +456,10 @@ class AnkiConnect:
@util.api() @util.api()
def getProfiles(self): def getProfiles(self):
return self.window().pm.profiles() return self.window().pm.profiles()
@util.api()
def getActiveProfile(self):
return self.window().pm.name
@util.api() @util.api()
def loadProfile(self, name): def loadProfile(self, name):
@ -1696,6 +1699,7 @@ class AnkiConnect:
result.append({ result.append({
'noteId': note.id, 'noteId': note.id,
'profile': self.window().pm.name,
'tags' : note.tags, 'tags' : note.tags,
'fields': fields, 'fields': fields,
'modelName': model['name'], 'modelName': model['name'],