diff options
Diffstat (limited to 'yt-dlp-best')
-rwxr-xr-x | yt-dlp-best | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/yt-dlp-best b/yt-dlp-best index 5c2f4cc..c6ab860 100755 --- a/yt-dlp-best +++ b/yt-dlp-best @@ -1,14 +1,25 @@ #!/usr/bin/env bash -USAGE="./yt-dlp-best \"URL\" - Fetches the best format of a YT video (ideally in mp4)" - -if [ $# -ne 1 ]; then - echo "$USAGE" - exit 1 +USAGE="./yt-dlp-best [options] \"URL\" + Fetches the best format of a YT video (ideally in mp4) + Options: + -y skips the format check normally requiring user action to continue with download" + +SKIP_CHECK=0 +if [ $# -eq 1 ]; then + URL=$1 +else + if [ $# -eq 2 ]; then + if [ "$1" == "-y" ]; then + SKIP_CHECK=1 + URL=$2 + fi + else + echo "$USAGE" + exit 1 + fi fi -URL=$1 DESIRED_FMT="mp4" FMT_LINE=$(yt-dlp -F "${URL}" | grep "${DESIRED_FMT}" | tail -n 1) @@ -16,7 +27,13 @@ FMT=$(echo ${FMT_LINE} | cut -d" " -f1) echo "${FMT_LINE}" echo "yt-dlp -f ${FMT}+m4a \"${URL}\"" -read -p "proceed (Y/N): " answer + +if [ $SKIP_CHECK -eq 0 ]; then + read -p "proceed (Y/N): " answer +else + # basically force a "yes" answer + answer="y" +fi if [[ "$answer" =~ ^[yY][eE]{0,1}[sS]{0,1}$ ]]; then yt-dlp -f ${FMT}+m4a "${URL}" |