-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
/close #101
- Loading branch information
Showing
11 changed files
with
154 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
#!/usr/bin/env bash | ||
source "$DOROTHY/sources/strict.bash" | ||
|
||
# FOR THUMBNAILS | ||
# AVIF is successor to WebP and the closed-source HEIF, however lacks wide support. | ||
# WebP is successor to the below, and offers wide support. | ||
# https://en.wikipedia.org/wiki/WebP | ||
# JPEG patent expired in 2006 | ||
# JPEG-2000 is free to use | ||
# PNG is an open-standard | ||
|
||
# FOR CONTAINER | ||
# https://en.wikipedia.org/wiki/Comparison_of_video_container_formats | ||
# MKV is living, open-source and royalty free. | ||
# WebM is VP9+Verbos only, it is royalty free, subset of MKV, wider support for ios, mac, and web browsers | ||
# MP4 is royalty free with expired patents, supported by absolutely everything, but less featured than MKV and a bit outdated. | ||
# https://en.wikipedia.org/wiki/ISO/IEC_base_media_file_format | ||
|
||
# FOR FORMAT | ||
# AV1 is royalty free and successor to VP9 and HEVC/H265, but no widespread hardware support | ||
# VP9 is royalty free and successor to VP8 and H264, with moderate hardware support | ||
# MP4/M4A is an affordable format which patents are still valid until 2023, with ubiquitous hardware support | ||
# https://meta.wikimedia.org/wiki/Have_the_patents_for_MPEG-4_Visual_expired_yet%3F | ||
# https://video.stackexchange.com/a/14699 | ||
# | ||
# AV1 playlist: | ||
# https://www.youtube.com/playlist?list=PLyqf6gJt7KuHBmeVzZteZUlNUQAVLwrZS | ||
# | ||
# AV1 is not viable without widespread hardware support: | ||
# https://en.wikipedia.org/wiki/AV1#Hardware | ||
# Running `ytd-helper --av1 BCmB-otRDeo` which is a 1 minute video, takes DAYS on a 2017 MacBook Pro. | ||
# Use `ytd-helper --vp9` instead until AV1 has widespread hardware support sometime in 2023-2025. | ||
|
||
# youtube-dl --help | ||
# --no-overwrites Do not overwrite files | ||
# --continue Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible. | ||
# --all-formats Download all available video formats | ||
# --all-subs Download all the available subtitles of the video | ||
# --geo-bypass Bypass geographic restriction via faking X-Forwarded-For HTTP header | ||
# --write-all-thumbnails Write all thumbnail image formats to disk | ||
# --write-annotations Write video annotations to a .annotations.xml file | ||
# --write-auto-sub Write automatically generated subtitle file (YouTube only) | ||
# --write-description Write video description to a .description file | ||
# --write-info-json Write video metadata to a .info.json file | ||
# --write-sub Write subtitle file | ||
|
||
# dependencies | ||
env QUIET=yes setup-util-jq | ||
|
||
# arguments | ||
args=() | ||
while test "$#" -ne 0; do | ||
item="$1" | ||
shift | ||
case "$item" in | ||
'--embed') | ||
args+=( | ||
--embed-subs | ||
--embed-thumbnail | ||
--add-metadata | ||
) | ||
;; | ||
'--archive') | ||
# get all formats, bt don't use embed as many formats don't support embedding | ||
args+=( | ||
--no-overwrites | ||
--continue | ||
--all-formats | ||
--all-subs | ||
--geo-bypass | ||
--write-all-thumbnails | ||
--write-annotations | ||
--write-auto-sub | ||
--write-description | ||
--write-info-json | ||
--write-sub | ||
) | ||
;; | ||
'--audio') | ||
args+=( | ||
--extract-audio | ||
--format | ||
'bestaudio[ext=m4a]' | ||
) | ||
;; | ||
'--audio+video') | ||
ytd --audio "${args[@]}" "$@" | ||
ytd "${args[@]}" "$@" | ||
return "$?" | ||
;; | ||
'--best') | ||
args+=( | ||
--format | ||
'best' | ||
) | ||
;; | ||
'--mp4') | ||
args+=( | ||
--recode-video | ||
'mp4' | ||
--merge-output-format | ||
'mp4' | ||
--format | ||
'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' | ||
) | ||
;; | ||
'--free') | ||
# `--prefer-free-formats` only prefers, it doesn't guarantee | ||
args+=( | ||
--format | ||
'(bestvideo[vcodec^=av01]/bestvideo[vcodec^=vp9])+bestaudio[acodec=opus]' | ||
) | ||
;; | ||
'--vp9') | ||
args+=( | ||
--recode-video | ||
'webm' | ||
--merge-output-format | ||
'webm' | ||
--format | ||
'(bestvideo[vcodec^=vp9]/bestvideo)+bestaudio[acodec=opus]' | ||
--postprocessor-args | ||
'-c:a libopus -c:v vp9 -strict experimental' | ||
) | ||
;; | ||
'--av1') | ||
args+=( | ||
--recode-video | ||
'mkv' | ||
--merge-output-format | ||
'mkv' | ||
--format | ||
'(bestvideo[vcodec^=av01]/bestvideo)+bestaudio[acodec=opus]' | ||
--postprocessor-args | ||
'-c:a libopus -c:v av1 -strict experimental' | ||
) | ||
;; | ||
'--playlist') | ||
args+=( | ||
--playlist-reverse | ||
--ignore-errors | ||
--output | ||
'%(playlist_id)s -- %(playlist_title)s/%(playlist_index)s/%(id)s -- %(title)s.%(ext)s' | ||
) | ||
;; | ||
*) | ||
args+=("$item") | ||
;; | ||
esac | ||
done | ||
|
||
# action | ||
echo-eval youtube-dl "${args[@]}" |