mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-11-16 07:48:01 +01:00
[utils, cleanup] Consolidate known media extensions
This commit is contained in:
parent
b4daacb4ec
commit
8dc5930511
6 changed files with 35 additions and 33 deletions
10
README.md
10
README.md
|
@ -916,7 +916,7 @@ You can also fork the project on github and run your fork's [build workflow](.gi
|
|||
(requires ffmpeg and ffprobe)
|
||||
--audio-format FORMAT Format to convert the audio to when -x is
|
||||
used. (currently supported: best (default),
|
||||
mp3, aac, m4a, opus, vorbis, flac, alac,
|
||||
aac, alac, flac, m4a, mp3, opus, vorbis,
|
||||
wav). You can specify multiple rules using
|
||||
similar syntax as --remux-video
|
||||
--audio-quality QUALITY Specify ffmpeg audio quality to use when
|
||||
|
@ -924,9 +924,9 @@ You can also fork the project on github and run your fork's [build workflow](.gi
|
|||
between 0 (best) and 10 (worst) for VBR or a
|
||||
specific bitrate like 128K (default 5)
|
||||
--remux-video FORMAT Remux the video into another container if
|
||||
necessary (currently supported: mp4, mkv,
|
||||
flv, webm, mov, avi, mka, ogg, mp3, aac,
|
||||
m4a, opus, vorbis, flac, alac, wav). If
|
||||
necessary (currently supported: avi, flv,
|
||||
mkv, mov, mp4, webm, aac, aiff, alac, flac,
|
||||
m4a, mka, mp3, ogg, opus, vorbis, wav). If
|
||||
target container does not support the
|
||||
video/audio codec, remuxing will fail. You
|
||||
can specify multiple rules; Eg.
|
||||
|
@ -1025,7 +1025,7 @@ You can also fork the project on github and run your fork's [build workflow](.gi
|
|||
be used multiple times
|
||||
--no-exec Remove any previously defined --exec
|
||||
--convert-subs FORMAT Convert the subtitles to another format
|
||||
(currently supported: srt, vtt, ass, lrc)
|
||||
(currently supported: ass, lrc, srt, vtt)
|
||||
(Alias: --convert-subtitles)
|
||||
--convert-thumbnails FORMAT Convert the thumbnails to another format
|
||||
(currently supported: jpg, png, webp). You
|
||||
|
|
|
@ -52,6 +52,7 @@ from .utils import (
|
|||
DEFAULT_OUTTMPL,
|
||||
IDENTITY,
|
||||
LINK_TEMPLATES,
|
||||
MEDIA_EXTENSIONS,
|
||||
NO_DEFAULT,
|
||||
NUMBER_RE,
|
||||
OUTTMPL_TYPES,
|
||||
|
@ -543,9 +544,9 @@ class YoutubeDL:
|
|||
'page_url', 'app', 'play_path', 'tc_url', 'flash_version', 'rtmp_live', 'rtmp_conn', 'rtmp_protocol', 'rtmp_real_time'
|
||||
}
|
||||
_format_selection_exts = {
|
||||
'audio': {'m4a', 'mp3', 'ogg', 'aac'},
|
||||
'video': {'mp4', 'flv', 'webm', '3gp'},
|
||||
'storyboards': {'mhtml'},
|
||||
'audio': set(MEDIA_EXTENSIONS.common_audio),
|
||||
'video': set(MEDIA_EXTENSIONS.common_video + ('3gp', )),
|
||||
'storyboards': set(MEDIA_EXTENSIONS.storyboards),
|
||||
}
|
||||
|
||||
def __init__(self, params=None, auto_init=True):
|
||||
|
|
|
@ -19,8 +19,8 @@ from .extractor.adobepass import MSO_INFO
|
|||
from .extractor.common import InfoExtractor
|
||||
from .options import parseOpts
|
||||
from .postprocessor import (
|
||||
FFmpegPostProcessor,
|
||||
FFmpegExtractAudioPP,
|
||||
FFmpegPostProcessor,
|
||||
FFmpegSubtitlesConvertorPP,
|
||||
FFmpegThumbnailsConvertorPP,
|
||||
FFmpegVideoConvertorPP,
|
||||
|
|
|
@ -972,7 +972,7 @@ def create_parser():
|
|||
}, help=(
|
||||
'Name or path of the external downloader to use (optionally) prefixed by '
|
||||
'the protocols (http, ftp, m3u8, dash, rstp, rtmp, mms) to use it for. '
|
||||
f'Currently supports native, {", ".join(list_external_downloaders())}. '
|
||||
f'Currently supports native, {", ".join(sorted(list_external_downloaders()))}. '
|
||||
'You can use this option multiple times to set different downloaders for different protocols. '
|
||||
'For example, --downloader aria2c --downloader "dash,m3u8:native" will use '
|
||||
'aria2c for http/ftp downloads, and the native downloader for dash/m3u8 downloads '
|
||||
|
@ -1469,7 +1469,7 @@ def create_parser():
|
|||
'--audio-format', metavar='FORMAT', dest='audioformat', default='best',
|
||||
help=(
|
||||
'Format to convert the audio to when -x is used. '
|
||||
f'(currently supported: best (default), {", ".join(FFmpegExtractAudioPP.SUPPORTED_EXTS)}). '
|
||||
f'(currently supported: best (default), {", ".join(sorted(FFmpegExtractAudioPP.SUPPORTED_EXTS))}). '
|
||||
'You can specify multiple rules using similar syntax as --remux-video'))
|
||||
postproc.add_option(
|
||||
'--audio-quality', metavar='QUALITY',
|
||||
|
@ -1652,13 +1652,13 @@ def create_parser():
|
|||
metavar='FORMAT', dest='convertsubtitles', default=None,
|
||||
help=(
|
||||
'Convert the subtitles to another format (currently supported: %s) '
|
||||
'(Alias: --convert-subtitles)' % ', '.join(FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS)))
|
||||
'(Alias: --convert-subtitles)' % ', '.join(sorted(FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS))))
|
||||
postproc.add_option(
|
||||
'--convert-thumbnails',
|
||||
metavar='FORMAT', dest='convertthumbnails', default=None,
|
||||
help=(
|
||||
'Convert the thumbnails to another format '
|
||||
f'(currently supported: {", ".join(FFmpegThumbnailsConvertorPP.SUPPORTED_EXTS)}). '
|
||||
f'(currently supported: {", ".join(sorted(FFmpegThumbnailsConvertorPP.SUPPORTED_EXTS))}). '
|
||||
'You can specify multiple rules using similar syntax as --remux-video'))
|
||||
postproc.add_option(
|
||||
'--split-chapters', '--split-tracks',
|
||||
|
|
|
@ -10,6 +10,7 @@ import time
|
|||
from .common import PostProcessor
|
||||
from ..compat import functools, imghdr
|
||||
from ..utils import (
|
||||
MEDIA_EXTENSIONS,
|
||||
ISO639Utils,
|
||||
Popen,
|
||||
PostProcessingError,
|
||||
|
@ -424,7 +425,7 @@ class FFmpegPostProcessor(PostProcessor):
|
|||
|
||||
|
||||
class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
COMMON_AUDIO_EXTS = ('wav', 'flac', 'm4a', 'aiff', 'mp3', 'ogg', 'mka', 'opus', 'wma')
|
||||
COMMON_AUDIO_EXTS = MEDIA_EXTENSIONS.common_audio + ('wma', )
|
||||
SUPPORTED_EXTS = tuple(ACODECS.keys())
|
||||
FORMAT_RE = create_mapping_re(('best', *SUPPORTED_EXTS))
|
||||
|
||||
|
@ -531,7 +532,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
|||
|
||||
|
||||
class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||
SUPPORTED_EXTS = ('mp4', 'mkv', 'flv', 'webm', 'mov', 'avi', 'mka', 'ogg', *FFmpegExtractAudioPP.SUPPORTED_EXTS)
|
||||
SUPPORTED_EXTS = (*MEDIA_EXTENSIONS.common_video, *sorted(MEDIA_EXTENSIONS.common_audio + ('aac', 'vorbis')))
|
||||
FORMAT_RE = create_mapping_re(SUPPORTED_EXTS)
|
||||
_ACTION = 'converting'
|
||||
|
||||
|
@ -924,7 +925,7 @@ class FFmpegFixupDuplicateMoovPP(FFmpegCopyStreamPP):
|
|||
|
||||
|
||||
class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor):
|
||||
SUPPORTED_EXTS = ('srt', 'vtt', 'ass', 'lrc')
|
||||
SUPPORTED_EXTS = MEDIA_EXTENSIONS.subtitles
|
||||
|
||||
def __init__(self, downloader=None, format=None):
|
||||
super().__init__(downloader)
|
||||
|
@ -1046,7 +1047,7 @@ class FFmpegSplitChaptersPP(FFmpegPostProcessor):
|
|||
|
||||
|
||||
class FFmpegThumbnailsConvertorPP(FFmpegPostProcessor):
|
||||
SUPPORTED_EXTS = ('jpg', 'png', 'webp')
|
||||
SUPPORTED_EXTS = MEDIA_EXTENSIONS.thumbnails
|
||||
FORMAT_RE = create_mapping_re(SUPPORTED_EXTS)
|
||||
|
||||
def __init__(self, downloader=None, format=None):
|
||||
|
|
|
@ -150,22 +150,6 @@ MONTH_NAMES = {
|
|||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
|
||||
}
|
||||
|
||||
KNOWN_EXTENSIONS = (
|
||||
'mp4', 'm4a', 'm4p', 'm4b', 'm4r', 'm4v', 'aac',
|
||||
'flv', 'f4v', 'f4a', 'f4b',
|
||||
'webm', 'ogg', 'ogv', 'oga', 'ogx', 'spx', 'opus',
|
||||
'mkv', 'mka', 'mk3d',
|
||||
'avi', 'divx',
|
||||
'mov',
|
||||
'asf', 'wmv', 'wma',
|
||||
'3gp', '3g2',
|
||||
'mp3',
|
||||
'mpg',
|
||||
'flac',
|
||||
'ape',
|
||||
'wav',
|
||||
'f4f', 'f4m', 'm3u8', 'smil')
|
||||
|
||||
# needed for sanitizing filenames in restricted mode
|
||||
ACCENT_CHARS = dict(zip('ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖŐØŒÙÚÛÜŰÝÞßàáâãäåæçèéêëìíîïðñòóôõöőøœùúûüűýþÿ',
|
||||
itertools.chain('AAAAAA', ['AE'], 'CEEEEIIIIDNOOOOOOO', ['OE'], 'UUUUUY', ['TH', 'ss'],
|
||||
|
@ -5647,6 +5631,22 @@ class Namespace(types.SimpleNamespace):
|
|||
return self.__dict__.items()
|
||||
|
||||
|
||||
MEDIA_EXTENSIONS = Namespace(
|
||||
common_video=('avi', 'flv', 'mkv', 'mov', 'mp4', 'webm'),
|
||||
video=('3g2', '3gp', 'f4v', 'mk3d', 'divx', 'mpg', 'ogv', 'm4v', 'wmv'),
|
||||
common_audio=('aiff', 'alac', 'flac', 'm4a', 'mka', 'mp3', 'ogg', 'opus', 'wav'),
|
||||
audio=('aac', 'ape', 'asf', 'f4a', 'f4b', 'm4b', 'm4p', 'm4r', 'oga', 'ogx', 'spx', 'vorbis', 'wma'),
|
||||
thumbnails=('jpg', 'png', 'webp'),
|
||||
storyboards=('mhtml', ),
|
||||
subtitles=('srt', 'vtt', 'ass', 'lrc'),
|
||||
manifests=('f4f', 'f4m', 'm3u8', 'smil', 'mpd'),
|
||||
)
|
||||
MEDIA_EXTENSIONS.video += MEDIA_EXTENSIONS.common_video
|
||||
MEDIA_EXTENSIONS.audio += MEDIA_EXTENSIONS.common_audio
|
||||
|
||||
KNOWN_EXTENSIONS = (*MEDIA_EXTENSIONS.video, *MEDIA_EXTENSIONS.audio, *MEDIA_EXTENSIONS.manifests)
|
||||
|
||||
|
||||
# Deprecated
|
||||
has_certifi = bool(certifi)
|
||||
has_websockets = bool(websockets)
|
||||
|
|
Loading…
Reference in a new issue