[DOCS] Add ffmpeg path docs (#487)
This commit is contained in:
parent
196b99ce0e
commit
7cfd14ed71
2 changed files with 25 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ from mergedeep import mergedeep
|
||||||
|
|
||||||
from ytdl_sub.prebuilt_presets import PREBUILT_PRESETS
|
from ytdl_sub.prebuilt_presets import PREBUILT_PRESETS
|
||||||
from ytdl_sub.utils.system import IS_WINDOWS
|
from ytdl_sub.utils.system import IS_WINDOWS
|
||||||
|
from ytdl_sub.validators.file_path_validators import ExistingFileValidator
|
||||||
from ytdl_sub.validators.strict_dict_validator import StrictDictValidator
|
from ytdl_sub.validators.strict_dict_validator import StrictDictValidator
|
||||||
from ytdl_sub.validators.validators import LiteralDictValidator
|
from ytdl_sub.validators.validators import LiteralDictValidator
|
||||||
from ytdl_sub.validators.validators import StringValidator
|
from ytdl_sub.validators.validators import StringValidator
|
||||||
|
|
@ -39,12 +40,11 @@ class ConfigOptions(StrictDictValidator):
|
||||||
self._lock_directory = self._validate_key(
|
self._lock_directory = self._validate_key(
|
||||||
key="lock_directory", validator=StringValidator, default=_DEFAULT_LOCK_DIRECTORY
|
key="lock_directory", validator=StringValidator, default=_DEFAULT_LOCK_DIRECTORY
|
||||||
)
|
)
|
||||||
# TODO: Validate these exist
|
|
||||||
self._ffmpeg_path = self._validate_key(
|
self._ffmpeg_path = self._validate_key(
|
||||||
key="ffmpeg_path", validator=StringValidator, default=_DEFAULT_FFMPEG_PATH
|
key="ffmpeg_path", validator=ExistingFileValidator, default=_DEFAULT_FFMPEG_PATH
|
||||||
)
|
)
|
||||||
self._ffprobe_path = self._validate_key(
|
self._ffprobe_path = self._validate_key(
|
||||||
key="ffprobe_path", validator=StringValidator, default=_DEFAULT_FFPROBE_PATH
|
key="ffprobe_path", validator=ExistingFileValidator, default=_DEFAULT_FFPROBE_PATH
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -102,14 +102,16 @@ class ConfigOptions(StrictDictValidator):
|
||||||
@property
|
@property
|
||||||
def ffmpeg_path(self) -> str:
|
def ffmpeg_path(self) -> str:
|
||||||
"""
|
"""
|
||||||
TODO: Fill out!
|
Optional. Path to ffmpeg executable. Defaults to ``/usr/bin/ffmpeg`` for Linux, and
|
||||||
|
``ffmpeg.exe`` for Windows (in the same directory as ytdl-sub).
|
||||||
"""
|
"""
|
||||||
return self._ffmpeg_path.value
|
return self._ffmpeg_path.value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ffprobe_path(self) -> str:
|
def ffprobe_path(self) -> str:
|
||||||
"""
|
"""
|
||||||
TODO: Fill out!
|
Optional. Path to ffprobe executable. Defaults to ``/usr/bin/ffprobe`` for Linux, and
|
||||||
|
``ffprobe.exe`` for Windows (in the same directory as ytdl-sub).
|
||||||
"""
|
"""
|
||||||
return self._ffprobe_path.value
|
return self._ffprobe_path.value
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,27 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from ytdl_sub.validators.string_formatter_validators import OverridesStringFormatterValidator
|
from ytdl_sub.validators.string_formatter_validators import OverridesStringFormatterValidator
|
||||||
from ytdl_sub.validators.string_formatter_validators import StringFormatterValidator
|
from ytdl_sub.validators.string_formatter_validators import StringFormatterValidator
|
||||||
|
from ytdl_sub.validators.validators import StringValidator
|
||||||
|
|
||||||
|
|
||||||
|
class ExistingFileValidator(StringValidator):
|
||||||
|
_expected_value_type_name = "file"
|
||||||
|
|
||||||
|
def __init__(self, name: str, value: Any):
|
||||||
|
super().__init__(name, value)
|
||||||
|
if not os.path.isfile(self._value):
|
||||||
|
raise self._validation_exception(
|
||||||
|
f"Expects an existing file, but '{self.value}' is not a file"
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self) -> str:
|
||||||
|
"""Turn into a Path, then a string, to get correct directory separators"""
|
||||||
|
return str(Path(self._value))
|
||||||
|
|
||||||
|
|
||||||
class StringFormatterFilePathValidator(StringFormatterValidator):
|
class StringFormatterFilePathValidator(StringFormatterValidator):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue