better docs
This commit is contained in:
parent
8d5d65a093
commit
94b8803a3f
3 changed files with 13 additions and 26 deletions
|
|
@ -8,7 +8,7 @@ from ytdl_sub.plugins.plugin import Plugin
|
|||
from ytdl_sub.plugins.plugin import PluginOptions
|
||||
from ytdl_sub.utils.exceptions import FileNotDownloadedException
|
||||
from ytdl_sub.validators.audo_codec_validator import AUDIO_CODEC_TYPES_EXTENSION_MAPPING
|
||||
from ytdl_sub.validators.audo_codec_validator import CodecTypeValidator
|
||||
from ytdl_sub.validators.audo_codec_validator import AudioTypeValidator
|
||||
from ytdl_sub.validators.validators import FloatValidator
|
||||
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ class AudioExtractOptions(PluginOptions):
|
|||
|
||||
def __init__(self, name, value):
|
||||
super().__init__(name, value)
|
||||
self._codec = self._validate_key(key="codec", validator=CodecTypeValidator).value
|
||||
self._codec = self._validate_key(key="codec", validator=AudioTypeValidator).value
|
||||
self._quality = self._validate_key_if_present(key="quality", validator=FloatValidator)
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ from ytdl_sub.plugins.plugin import Plugin
|
|||
from ytdl_sub.plugins.plugin import PluginOptions
|
||||
from ytdl_sub.utils.exceptions import FileNotDownloadedException
|
||||
from ytdl_sub.utils.file_handler import FileMetadata
|
||||
from ytdl_sub.validators.audo_codec_validator import VideoCodecTypeValidator
|
||||
from ytdl_sub.validators.audo_codec_validator import FileTypeValidator
|
||||
|
||||
|
||||
class FileConvertOptions(PluginOptions):
|
||||
"""
|
||||
Converts media files from one extension to another.
|
||||
Converts video files from one extension to another.
|
||||
|
||||
Usage:
|
||||
|
||||
|
|
@ -30,13 +30,16 @@ class FileConvertOptions(PluginOptions):
|
|||
def __init__(self, name, value):
|
||||
super().__init__(name, value)
|
||||
self._convert_to = self._validate_key(
|
||||
key="convert_to", validator=VideoCodecTypeValidator
|
||||
key="convert_to", validator=FileTypeValidator
|
||||
).value
|
||||
|
||||
@property
|
||||
def convert_to(self) -> str:
|
||||
"""
|
||||
Convert to a desired extension
|
||||
Convert to a desired file type. Supports:
|
||||
|
||||
* Video: avi, flv, mkv, mov, mp4, webm
|
||||
* Audio: aac, flac, mp3, m4a, opus, vorbis, wav
|
||||
"""
|
||||
return self._convert_to
|
||||
|
||||
|
|
|
|||
|
|
@ -16,30 +16,14 @@ AUDIO_CODEC_TYPES_EXTENSION_MAPPING: Dict[str, str] = {
|
|||
AUDIO_CODEC_TYPES: Set[str] = set(AUDIO_CODEC_TYPES_EXTENSION_MAPPING.keys())
|
||||
AUDIO_CODEC_EXTS: Set[str] = set(AUDIO_CODEC_TYPES_EXTENSION_MAPPING.values())
|
||||
|
||||
VIDEO_CODEC_EXTS: Set[str] = {
|
||||
"avi",
|
||||
"flv",
|
||||
"mkv",
|
||||
"mov",
|
||||
"mp4",
|
||||
"webm",
|
||||
"3g2",
|
||||
"3gp",
|
||||
"f4v",
|
||||
"mk3d",
|
||||
"divx",
|
||||
"mpg",
|
||||
"ogv",
|
||||
"m4v",
|
||||
"wmv",
|
||||
}
|
||||
VIDEO_CODEC_EXTS: Set[str] = {"avi", "flv", "mkv", "mov", "mp4", "webm"}
|
||||
|
||||
|
||||
class CodecTypeValidator(StringSelectValidator):
|
||||
class AudioTypeValidator(StringSelectValidator):
|
||||
_expected_value_type_name = "codec"
|
||||
_select_values = AUDIO_CODEC_TYPES
|
||||
|
||||
|
||||
class VideoCodecTypeValidator(StringSelectValidator):
|
||||
class FileTypeValidator(StringSelectValidator):
|
||||
_expected_value_type_name = "codec"
|
||||
_select_values = VIDEO_CODEC_EXTS
|
||||
_select_values = AUDIO_CODEC_TYPES.union(VIDEO_CODEC_EXTS)
|
||||
|
|
|
|||
Loading…
Reference in a new issue