Combines node scripts and adds other scripts from vogon.
This commit is contained in:
55
.rc.d/yt-dlp.sh
Normal file
55
.rc.d/yt-dlp.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
# Define yt-dlp functions with dynamic JavaScript runtime (Node.js) detection
|
||||
yt-dlp() {
|
||||
local _cmd="yt-dlp"
|
||||
if ! command -v yt-dlp >/dev/null 2>&1; then
|
||||
if [ -x "/opt/homebrew/bin/yt-dlp" ]; then
|
||||
_cmd="/opt/homebrew/bin/yt-dlp"
|
||||
elif [ -x "/usr/local/bin/yt-dlp" ]; then
|
||||
_cmd="/usr/local/bin/yt-dlp"
|
||||
elif [ -x "$HOME/.local/bin/yt-dlp" ]; then
|
||||
_cmd="$HOME/.local/bin/yt-dlp"
|
||||
else
|
||||
echo "yt-dlp: command not found" >&2
|
||||
return 127
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
command $_cmd --js-runtimes "node:$(command -v node)" "$@"
|
||||
else
|
||||
command $_cmd "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
yt-dlp-best() {
|
||||
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]" "$@"
|
||||
}
|
||||
|
||||
yt-dlp-audio-meta() {
|
||||
yt-dlp \
|
||||
-f "ba[ext=m4a]/ba" \
|
||||
-x --audio-format m4a \
|
||||
--embed-metadata --embed-thumbnail \
|
||||
"$@"
|
||||
}
|
||||
|
||||
yt-dlp-formats() {
|
||||
yt-dlp -F "$@"
|
||||
}
|
||||
|
||||
yt-dlp-playlist-audio() {
|
||||
yt-dlp \
|
||||
--yes-playlist \
|
||||
--embed-metadata --embed-thumbnail \
|
||||
-f "ba[ext=m4a]/ba" \
|
||||
-o "%(playlist_title,playlist_id)s/%(playlist_index)03d - %(title)s.%(ext)s" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
yt-dlp-playlist() {
|
||||
yt-dlp \
|
||||
--yes-playlist \
|
||||
--embed-metadata --embed-thumbnail \
|
||||
-o "%(playlist_title,playlist_id)s/%(playlist_index)03d - %(title)s.%(ext)s" \
|
||||
"$@"
|
||||
}
|
||||
Reference in New Issue
Block a user