From e1efe51f4fe1bb0ec89383b146f395a08dd891de Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Mon, 19 Aug 2024 09:54:31 -0400 Subject: 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. --- yt-dlp-best | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 yt-dlp-best 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 + + -- cgit v1.2.3-54-g00ecf