From 0514569621f428835c3da6894727ba5e2c5af864 Mon Sep 17 00:00:00 2001 From: Diogo Cadavez Date: Tue, 2 Jul 2024 15:27:19 +0200 Subject: [PATCH] added method to retrieve the active profile --- README.md | 33 +++++++++++++++++++++++++++++++-- plugin/__init__.py | 6 +++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a0a0f37..7d0f0ea 100644 --- a/README.md +++ b/README.md @@ -2132,6 +2132,33 @@ Search parameters are passed to Anki, check the docs for more information: https ``` +#### `getActiveProfile` + +* Retrieve the active profile. + +
+ Sample request: + + ```json + { + "action": "getActiveProfile", + "version": 6 + } + ``` +
+ +
+ Sample result: + + ```json + { + "result": "User 1", + "error": null + } + ``` +
+ + #### `loadProfile` * Selects the profile specified in request. @@ -4147,8 +4174,8 @@ Search parameters are passed to Anki, check the docs for more information: https #### `notesInfo` -* Returns a list of objects containing for each note ID the note fields, tags, note type, modification time and the cards belonging to - the note. +* Returns a list of objects containing for each note ID the note fields, tags, note type, modification time,the cards belonging to + the note and the profile where the note was created.
Sample request: @@ -4172,6 +4199,7 @@ Search parameters are passed to Anki, check the docs for more information: https "result": [ { "noteId":1502298033753, + "profile": "User_1", "modelName": "Basic", "tags":["tag","another_tag"], "fields": { @@ -4179,6 +4207,7 @@ Search parameters are passed to Anki, check the docs for more information: https "Back": {"value": "back content", "order": 1} }, "mod": 1718377864, + "cards": [1498938915662] } ], "error": null diff --git a/plugin/__init__.py b/plugin/__init__.py index 44e5e58..c4b59fc 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -456,7 +456,10 @@ class AnkiConnect: @util.api() def getProfiles(self): return self.window().pm.profiles() - + + @util.api() + def getActiveProfile(self): + return self.window().pm.name @util.api() def loadProfile(self, name): @@ -1696,6 +1699,7 @@ class AnkiConnect: result.append({ 'noteId': note.id, + 'profile': self.window().pm.name, 'tags' : note.tags, 'fields': fields, 'modelName': model['name'],