Merge pull request #379 from Ajatt-Tools/master
This commit is contained in:
commit
bf5c73b9cd
26
README.md
26
README.md
@ -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.
|
||||||
|
@ -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):
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import base64
|
import base64
|
||||||
|
import os.path
|
||||||
|
|
||||||
from conftest import ac
|
from conftest import ac
|
||||||
|
|
||||||
@ -49,3 +50,7 @@ def test_deleteMediaFile(session_with_profile_loaded):
|
|||||||
ac.deleteMediaFile(filename=filename_1)
|
ac.deleteMediaFile(filename=filename_1)
|
||||||
assert ac.retrieveMediaFile(filename=filename_1) is False
|
assert ac.retrieveMediaFile(filename=filename_1) is False
|
||||||
assert ac.getMediaFilesNames(pattern="_tes*.txt") == [filename_2]
|
assert ac.getMediaFilesNames(pattern="_tes*.txt") == [filename_2]
|
||||||
|
|
||||||
|
|
||||||
|
def test_getMediaDirPath(session_with_profile_loaded):
|
||||||
|
assert os.path.isdir(ac.getMediaDirPath())
|
||||||
|
Loading…
Reference in New Issue
Block a user