add a new action: getMediaDirPath

This commit is contained in:
Ren Tatsumoto 2023-03-21 19:46:55 +03:00
parent 5b6fe5766c
commit 58283bdeb5
2 changed files with 29 additions and 0 deletions

View File

@ -1759,6 +1759,32 @@ corresponding to when the API was available for use.
``` ```
</details> </details>
#### `getMediaDirPath`
* Gets the full path to the `collection.media` folder of the currently opened profile.
<details>
<summary><i>Sample request:</i></summary>
```json
{
"action": "getMediaDirPath",
"version": 6
}
```
</details>
<details>
<summary><i>Sample result:</i></summary>
```json
{
"result": "/home/user/.local/share/Anki2/Main/collection.media",
"error": null
}
```
</details>
#### `deleteMediaFile` #### `deleteMediaFile`
* Deletes the specified file inside the media folder. * Deletes the specified file inside the media folder.

View File

@ -722,6 +722,9 @@ class AnkiConnect:
except AttributeError: except AttributeError:
self.media().trash_files([filename]) self.media().trash_files([filename])
@util.api()
def getMediaDirPath(self):
return os.path.abspath(self.media().dir())
@util.api() @util.api()
def addNote(self, note): def addNote(self, note):