Skip to content

Instantly share code, notes, and snippets.

@Nioub
Forked from lwr/ytdl
Last active August 29, 2015 14:14
Show Gist options
  • Save Nioub/cdff8845ad383aa8be02 to your computer and use it in GitHub Desktop.
Save Nioub/cdff8845ad383aa8be02 to your computer and use it in GitHub Desktop.
Recent versions of youtube-dl handles recombination if ffmpeg is in PATH
#!/bin/bash
#Youtube-DL DASH Video and Audio merging script
#Written by QuidsUp
#Edited by Christoph Korn
#Edited by William Leung
#Edited by Joel Thieffry
URL=$1
if [ -z $URL ]; then
echo "Usage: ytdl.sh url"
exit
fi
#Find what quality of videos are available
youtube-dl -F $URL
echo
echo -n "Quality for Video (default 137): "
read Qual1
echo -n "Quality for Audio (default 141): "
read Qual2
#Set values if user has just pressed Return without typing anything
if [ -z $Qual1 ]; then
Qual1="137"
fi
if [ -z $Qual2 ]; then
Qual2="141"
fi
#Set filenames from output of youtube-dl
File1=$(youtube-dl --get-filename -f $Qual1 $URL)
echo $File1
#Download Video file with First Quality Setting
# + Audio file with Second Quality Setting
# then recombine them with ffmpeg
youtube-dl -f $Qual1+$Qual2 $URL
if [[ ! -f $File1 ]]; then
echo
echo "Error video file not downloaded"
exit
fi
echo "Video file downloaded successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment