summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteph Enders <steph@senders.io>2024-10-13 09:36:15 -0400
committerSteph Enders <steph@senders.io>2024-10-13 09:39:52 -0400
commitf444dbcb4c4b8f728c4a4f9215a4452562cabc7a (patch)
treeedf3d8907cb78df9dabbd6c10ef216c72ca4e677
parentc02e9371462308e53c337807b9bc3ee11a964ae0 (diff)
Allow the passing of -y to the command to skip format checkmain
-y can be passed now as the first argument such as: yt-dlp-best -y "URL" this is a naive implementation given its positionally required as well as directly forcing into the answer check flow rather than separating out the execution logic into a subfunction and calling it. Technically speaking this executes in bash so that'd be fine. I just figured this would be easier to follow down the line. idk.
-rwxr-xr-xyt-dlp-best33
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}"