Created
March 11, 2023 22:38
-
-
Save garethnunns/034410b157e47556ccd8963c4286b347 to your computer and use it in GitHub Desktop.
Download YouTube videos at high quality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # check yt-dlp is installed (and if not install it via Homebrew) | |
| which -s yt-dlp | |
| if [[ $? != 0 ]] ; then | |
| # check Homebrew is installed (and if not install it) | |
| which -s brew | |
| if [[ $? != 0 ]] ; then | |
| # Install Homebrew | |
| ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
| fi | |
| brew install yt-dlp | |
| fi | |
| echo "Checking for updates" | |
| brew upgrade yt-dlp | |
| echo "Enter YouTube link" | |
| read videoLink | |
| echo Downloading $videoLink | |
| videoPath=$(yt-dlp -f "bv*+ba/b" -v --print after_move:filepath --merge-output-format "mp4" -o "%(title)s %(display_id)s.%(ext)s" $videoLink) | |
| echo Converting $videoPath | |
| mv "$videoPath" downloaded.mp4 | |
| ffmpeg -i downloaded.mp4 -vcodec libx264 -acodec aac "$videoPath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment