mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 22:13:58 -05:00
check if file exist
AJT Japanese needs to play files stored in all possible locations on disk
This commit is contained in:
parent
4bf7e3b2b6
commit
621ea21706
1 changed files with 1 additions and 15 deletions
|
|
@ -46,22 +46,8 @@ from aqt.utils import (
|
|||
##########################################################################
|
||||
|
||||
|
||||
def is_in_any_collection(file_path: str) -> bool:
|
||||
from aqt import mw
|
||||
|
||||
file_dir = os.path.dirname(file_path) # should be "/path/to/collection.media"
|
||||
profile_dir = os.path.dirname(file_dir) # e.g. "/path/to/User 1"
|
||||
return (
|
||||
os.path.basename(file_dir) == "collection.media"
|
||||
and os.path.basename(profile_dir) in mw.pm.profiles()
|
||||
and os.path.dirname(profile_dir) == mw.pm.base
|
||||
)
|
||||
|
||||
|
||||
def resolve_tag_path(tag: SoundOrVideoTag, media_folder: str) -> str:
|
||||
file_path = (
|
||||
tag.filename if is_in_any_collection(tag.filename) else tag.path(media_folder)
|
||||
)
|
||||
file_path = tag.filename if os.path.isfile(tag.filename) else tag.path(media_folder)
|
||||
return hooks.media_file_filter(file_path)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue