diff options
author | Steph Enders <steph@senders.io> | 2024-08-19 09:54:31 -0400 |
---|---|---|
committer | Steph Enders <steph@senders.io> | 2024-08-19 09:54:31 -0400 |
commit | e1efe51f4fe1bb0ec89383b146f395a08dd891de (patch) | |
tree | 08aa3194f1ee008c7e1c5b56862f008413dddad8 |
Create basic script to download "best" format of YT video
Known quirks:
if the best two formats are mp4 the FMT_LINE will have 2 lines in it;
it currently assumes the top two are webm and mp4, but this is a quick
fix I'll likely do in a later commit. (just swap the grep and tail -n
1)
We just force m4a as the audio but this may not be optimal; you can
get the audio formats and merging the two best may be the best
situation especailly for audio focused things like a music video or
something.
-rwxr-xr-x | yt-dlp-best | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/yt-dlp-best b/yt-dlp-best new file mode 100755 index 0000000..9b239f0 --- /dev/null +++ b/yt-dlp-best @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +USAGE="Fetches the best format of a YT video (ideally in mp4) +yt-dlp-best \"URL\" +" + +if [ $# -ne 1 ]; then + echo $USAGE + exit 1 +fi + +URL=$1 + +FMT_LINE=$(yt-dlp -F "${URL}" | tail -n 2 | grep "mp4") + +FMT=$(echo ${FMT_LINE} | cut -d" " -f1) + +echo "${FMT_LINE}" +echo "yt-dlp -f ${FMT}+m4a \"${URL}\"" +read -p "proceed (Y/N): " answer + +if [[ "$answer" =~ ^[yY][eE]{0,1}[sS]{0,1}$ ]]; then + yt-dlp -f ${FMT}+m4a "${URL}" + exit 0 +else + echo "Okay, cancelling" + exit 1 +fi + + |