[DOCS] file_convert plugin (#276)
* [DOCS] file_convert plugin * better docs * lint
This commit is contained in:
parent
cfc2e916aa
commit
4ddaf72ae1
4 changed files with 19 additions and 28 deletions
|
|
@ -188,6 +188,12 @@ date_range
|
|||
:members:
|
||||
:member-order: bysource
|
||||
|
||||
file_convert
|
||||
''''''''''''
|
||||
.. autoclass:: ytdl_sub.plugins.file_convert.FileConvertOptions()
|
||||
:members:
|
||||
:member-order: bysource
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
music_tags
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
@ -29,14 +29,15 @@ class FileConvertOptions(PluginOptions):
|
|||
|
||||
def __init__(self, name, value):
|
||||
super().__init__(name, value)
|
||||
self._convert_to = self._validate_key(
|
||||
key="convert_to", validator=VideoCodecTypeValidator
|
||||
).value
|
||||
self._convert_to = self._validate_key(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