commit 5f1d05d893c078824d6fe5a659f4d653a8397568
parent 2593b375b5efca7af932912a8edb1669b2df7931
Author: regexghost <dev@regexghost.com>
Date: Sat, 20 Jun 2026 21:29:46 +0100
ytdl-wrapper.sh added. and aliases updated. Moved this out of shell rc file, as it uses a lot of bashisms so isn't compatible with my oksh setup
Diffstat:
3 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/dotfiles/.kshrc b/dotfiles/.kshrc
@@ -240,8 +240,8 @@ t () {
#### Start Substitute - Power_Management
-## Alias to allow escaping with backslash
-alias yt-dlp='do_yt-dlp'
+## Wrapper script
+alias yt-dlp='ytdl-wrapper'
yt-playlist () {
quality_option="--720p"
@@ -249,7 +249,7 @@ yt-playlist () {
quality_option="--1080p"
shift
fi
- do_yt-dlp --playlist-order --all-metadata --firefox-cookies --aria --archive "$quality_option" "$@"
+ ytdl-wrapper --playlist-order --all-metadata --firefox-cookies --aria --archive "$quality_option" "$@"
}
archivevideo() {
diff --git a/terminal-scripts/Makefile b/terminal-scripts/Makefile
@@ -29,3 +29,4 @@ normal:
cp webm_to_m4a.sh ${BIN}/webm_to_m4a
gcc string-trunc.c -o string-trunc
mv string-trunc ${BIN}/string-trunc
+ cp ytdl-wrapper.sh ${BIN}/ytdl-wrapper
diff --git a/terminal-scripts/ytdl-wrapper.sh b/terminal-scripts/ytdl-wrapper.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+
+# yt-dlp wrapper script
+
+aria_args=()
+metadata_args=()
+cookies_args=()
+archive_args=()
+other_args=()
+output_format_args=(-o "%(title)s.%(ext)s")
+format_args=()
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --aria)
+ aria_args+=("--external-downloader" "aria2c" "--external-downloader-args" "aria2c:-x 16 -j 16 -s 16 -k 1M")
+ shift
+ ;;
+ --aria-limit)
+ download_limit="3"
+ num_re='^[0-9]+M*$'
+ if [[ "$2" =~ $num_re ]]; then
+ download_limit="${2//M}"
+ shift
+ fi
+ aria_args+=("--external-downloader" "aria2c" "--external-downloader-args" "aria2c:-x 16 -j 16 -s 16 -k 1M --max-overall-download-limit=${download_limit}M")
+ shift
+ ;;
+ --all-metadata)
+ metadata_args+=("--embed-chapters" "--embed-thumbnail" "--embed-metadata")
+ shift
+ ;;
+ --music)
+ output_format_args=(-o "%(title)s -- %(channel)s -- %(album)s.%(ext)s")
+ format_args=(-f 140)
+ shift
+ ;;
+ --playlist-order)
+ output_format_args=(-o "%(playlist_index)s-%(title)s.%(ext)s")
+ shift
+ ;;
+ --standard)
+ format_args=(-f "22/bestvideo[height<=720]+bestaudio")
+ shift
+ ;;
+ --firefox-cookies)
+ cookies_args=("--cookies-from-browser" "firefox")
+ shift
+ ;;
+ --archive)
+ archive_args=("--download-archive" "archive.txt")
+ shift
+ ;;
+ --1080p)
+ format_args=("-f" "bestvideo[height<=1080][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]")
+ shift
+ ;;
+ --720p)
+ format_args=("-f" "bestvideo[height<=720][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]")
+ shift
+ ;;
+ --480p)
+ format_args=("-f" "bestvideo[height<=480][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]")
+ shift
+ ;;
+ --360p)
+ format_args=("-f" "bestvideo[height<=360][protocol=https][vcodec*=avc]+bestaudio[ext=m4a]")
+ shift
+ ;;
+ *)
+ other_args+=("$1")
+ shift
+ ;;
+ esac
+done
+
+all_args=("${output_format_args[@]}" "${aria_args[@]}" "${metadata_args[@]}" "${cookies_args[@]}" "${format_args[@]}" "${archive_args[@]}" "${other_args[@]}" "$@")
+/usr/bin/yt-dlp "${all_args[@]}"