This repository was archived by the owner on Nov 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1759,6 +1759,32 @@ corresponding to when the API was available for use.
17591759 ```
17601760 </details>
17611761
1762+ #### `getMediaDirPath`
1763+
1764+ * Gets the full path to the `collection.media` folder of the currently opened profile.
1765+
1766+ <details>
1767+ <summary><i>Sample request:</i></summary>
1768+
1769+ ```json
1770+ {
1771+ "action": "getMediaDirPath",
1772+ "version": 6
1773+ }
1774+ ```
1775+ </details>
1776+
1777+ <details>
1778+ <summary><i>Sample result:</i></summary>
1779+
1780+ ```json
1781+ {
1782+ "result": "/home/user/.local/share/Anki2/Main/collection.media",
1783+ "error": null
1784+ }
1785+ ```
1786+ </details>
1787+
17621788#### `deleteMediaFile`
17631789
17641790* Deletes the specified file inside the media folder.
Original file line number Diff line number Diff line change @@ -722,6 +722,9 @@ def deleteMediaFile(self, filename):
722722 except AttributeError :
723723 self .media ().trash_files ([filename ])
724724
725+ @util .api ()
726+ def getMediaDirPath (self ):
727+ return os .path .abspath (self .media ().dir ())
725728
726729 @util .api ()
727730 def addNote (self , note ):
Original file line number Diff line number Diff line change 11import base64
2+ import os .path
23
34from conftest import ac
45
@@ -49,3 +50,7 @@ def test_deleteMediaFile(session_with_profile_loaded):
4950 ac .deleteMediaFile (filename = filename_1 )
5051 assert ac .retrieveMediaFile (filename = filename_1 ) is False
5152 assert ac .getMediaFilesNames (pattern = "_tes*.txt" ) == [filename_2 ]
53+
54+
55+ def test_getMediaDirPath (session_with_profile_loaded ):
56+ assert os .path .isdir (ac .getMediaDirPath ())
You can’t perform that action at this time.
0 commit comments