Files
Linux_post_install/bin/pos-media-mp4
T

39 lines
780 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# POS: media mp4 — Download video as MP4 (interactive format select)
source "$(dirname "$0")/../lib/common.sh" 2>/dev/null || source "$(dirname "$0")/common.sh"
usage() {
cat <<EOF
Usage: pos media mp4 <url>
Download video from a URL via yt-dlp with interactive format selection.
Examples:
pos media mp4 https://youtube.com/watch?v=dQw4w9WgXcQ
EOF
exit 0
}
case "${1:-}" in
-h|--help|"") usage ;;
esac
command -v yt-dlp &>/dev/null || err "yt-dlp not found — install it with: sudo apt install yt-dlp"
url="$1"
yt-dlp -F "$url"
echo
read -rp "Enter format ID: " format
yt-dlp \
-f "$format" \
--merge-output-format mp4 \
--embed-thumbnail \
--add-metadata \
-o "$HOME/Videos/%(title)s.%(ext)s" \
"$url"