mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-01 20:32:54 +08:00
First pass at smallestvideo/smallestaudio filters
This commit is contained in:
parent
2791e80b60
commit
3a3b57cc23
@ -647,8 +647,10 @@ You can also use special names to select particular edge case formats:
|
||||
- `worst`: Select the worst quality format represented by a single file with video and audio.
|
||||
- `bestvideo`: Select the best quality video-only format (e.g. DASH video). May not be available.
|
||||
- `worstvideo`: Select the worst quality video-only format. May not be available.
|
||||
- `smallestvideo`: Select the smallest video-only format. May not be available.
|
||||
- `bestaudio`: Select the best quality audio only-format. May not be available.
|
||||
- `worstaudio`: Select the worst quality audio only-format. May not be available.
|
||||
- `smallestaudio`: Select the smallest audio-only format. May not be available.
|
||||
|
||||
For example, to download the worst quality video-only format you can use `-f worstvideo`.
|
||||
|
||||
|
@ -1283,6 +1283,13 @@ class YoutubeDL(object):
|
||||
if f.get('vcodec') == 'none']
|
||||
if audio_formats:
|
||||
yield audio_formats[0]
|
||||
elif format_spec == 'smallestaudio':
|
||||
video_formats = [
|
||||
f for f in formats
|
||||
if f.get('vcodec') == 'none']
|
||||
audio_formats = sorted(audio_formats, key=lambda format: format['filesize'])
|
||||
if audio_formats:
|
||||
yield audio_formats[0]
|
||||
elif format_spec == 'bestvideo':
|
||||
video_formats = [
|
||||
f for f in formats
|
||||
@ -1295,6 +1302,13 @@ class YoutubeDL(object):
|
||||
if f.get('acodec') == 'none']
|
||||
if video_formats:
|
||||
yield video_formats[0]
|
||||
elif format_spec == 'smallestvideo':
|
||||
video_formats = [
|
||||
f for f in formats
|
||||
if f.get('acodec') == 'none']
|
||||
video_formats = sorted(video_formats, key=lambda format: format['filesize'])
|
||||
if video_formats:
|
||||
yield video_formats[0]
|
||||
else:
|
||||
extensions = ['mp4', 'flv', 'webm', '3gp', 'm4a', 'mp3', 'ogg', 'aac', 'wav']
|
||||
if format_spec in extensions:
|
||||
|
Loading…
Reference in New Issue
Block a user