Skip to content

Commit 3e229e0

Browse files
committed
updated youtube_download_video.sh
1 parent 2541b04 commit 3e229e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: media/youtube_download_video.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ max_args 2 "$@"
4747
url="$1"
4848
output_filename="${2:-%(title)s}.%(ext)s"
4949

50+
format="bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4]"
51+
5052
#"$srcdir/../packages/install_packages_if_absent.sh" yt-dlp ffmpeg
5153

5254
# in case installed manually but not in package manager
@@ -82,7 +84,7 @@ done
8284
# --output "%(title)s.%(ext)s" \
8385
#
8486
yt-dlp \
85-
--format "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=mp4]" \
87+
--format "$format" \
8688
--merge-output-format mp4 \
8789
--continue \
8890
--no-overwrite \
@@ -102,7 +104,9 @@ else
102104
# the wrong video
103105
#"$srcdir/vidopen.sh" "$(ls -t ./*.mp4 | head -n1)"
104106
timestamp "Determining download filename"
105-
filename="$(yt-dlp --get-filename --output "$output_filename" "$url")"
107+
# "$format" is only needed here for it to return the right file extension
108+
# in the "$output_filename" format eg. '.mp4' instead of '.webm'
109+
filename="$(yt-dlp --get-filename --format "$format" --output "$output_filename" "$url")"
106110
fi
107111
if ! [ -f "$filename" ]; then
108112
die "Failed to find expected output file: $filename"

0 commit comments

Comments
 (0)