#!/bin/bashVERSION="1.3.2"YOUTUBE_DL="youtube-dl"YOUTUBE_DL="/home/pfinlayson/.local/bin/youtube-dl"YOUTUBE_DL="/home/pfinlayson/.local/bin/yt-dlp"MP4_FORMAT="137+140"declare -a args
quiet_mode=""output_template_default="%(title)s-%(id)s.%(ext)s"output_template_twitch="%(id)s-%(title)s.%(ext)s"output_template="$output_template_default"TWITCH_RE='^(http[s]?://)?([A-Za-z0-9]*[.])?twitch.tv/'function usage {echo"$(basename $0)$VERSION - Wrapper script for youtube-dl"echo" Usage: $(basename $0) <url>"echo" -F List of available audio and video formats"echo" -f FORMAT Download the video using FORMAT"echo" --mp4 Download a 1080p MP4 with AAC audio (if available)"echo"For more information about the optiona available in the base tool, run:"echo" '$YOUTUBE_DL' --help"}# parse the command linefunction parse_args {local arg
for arg in "$@";docase"$arg" in
-h|--help) usage
exit0;; -v|--version) usage
exit0;; --mp4)args+=("-f""$MP4_FORMAT");; -q|--quiet)args+=("$arg")quiet_mode="true";; *)# switch to twitch names maybe[["$arg"=~ $TWITCH_RE]]&&output_template="$output_template_twitch"# pass the arg to youtube-dlargs+=("$arg");;esacdone}parse_args "$@"[[ -z "$quiet_mode"]]&&echo youtube-dl -o "$output_template" --restrict-filenames --no-mtime "${args[@]}"exec"$YOUTUBE_DL" -o "$output_template" --restrict-filenames --no-mtime "${args[@]}"
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.