Last active
June 12, 2020 18:52
-
-
Save sarojbelbase/10211d178b0d07cb9faebe6995947162 to your computer and use it in GitHub Desktop.
A bash script that downloads youtube videos from 1080p to 4K, 320kbps audio mp3 & even any playlist both in audio & video version.
This file contains 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 | |
# This bash script downloads youtube videos, playlists from 4K to 1080p & even extracts to mp3 using youtube-dl. | |
# This script also depends on 'ffmpeg' or 'avconv' so either of them needs to be installed. | |
# To run this script: | |
# 1. Simply download this gist and save it as youtube.sh | |
# 2. In bash type "bash youtube.sh" without inverted comma | |
function main_menu() { | |
clear | |
echo "" | |
echo -e "Download youtube video, playlists extract them to your like, just in your browser." | |
echo "" | |
echo -e "1. Download Video" | |
echo -e "2. Download Audio" | |
echo -e "3. Download Playlist [Video Version]" | |
echo -e "4. Download Playlist [Audio Version]" | |
echo -e "5. Just Quit" | |
echo -e "" | |
echo -e "Enter a number to start, eg: enter 1 to download a video" | |
echo -e "" | |
echo -e "Enter any magical number: " | |
read choice | |
case $choice in | |
1) video_only ;; | |
2) audio_only ;; | |
3) video_playlist ;; | |
4) audio_playlist ;; | |
5) close ;; | |
*) | |
clear | |
echo "" | |
echo -e "Your choice \"$choice\" is kinda invalid." | |
echo "" | |
sleep 3;; | |
esac | |
} | |
function video_only(){ | |
clear | |
printf "%s\n" "" "Paste a youtube video link: " "" | |
read link | |
youtube-dl -F "$link" | |
printf "%s\n" "" "Enter your desired video format & resolution from the list above" "" | |
read list | |
clear | |
youtube-dl --continue --format "$list"+bestaudio[ext=m4a] --output "/home/$USER/Downloads/Youtubes/%(title)s.%(ext)s" --merge-output-format mp4 "$link" | |
sleep 3 | |
main_menu | |
} | |
function audio_only(){ | |
clear | |
printf "%s\n" "" "Paste a youtube video link: " "" | |
read link | |
clear | |
youtube-dl --continue --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/Youtubes/%(title)s.%(ext)s" "$link" | |
sleep 3 | |
main_menu | |
} | |
function audio_playlist(){ | |
clear | |
printf "%s\n" "" "Paste the link of a youtube playlist: " "" | |
read link | |
clear | |
youtube-dl --continue --yes-playlist --ignore-errors --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/Youtubes/%(title)s.%(ext)s" "$link" | |
sleep 3 | |
main_menu | |
} | |
function video_playlist(){ | |
clear | |
printf "%s\n" "" "Paste the link of a youtube playlist: " "" | |
read link | |
clear | |
youtube-dl --continue --yes-playlist --format bestvideo[height=1080]+bestaudio[ext=m4a] --ignore-errors --output "/home/$USER/Downloads/Youtubes/%(title)s.%(ext)s" "$link" | |
sleep 3 | |
main_menu | |
} | |
function close(){ | |
clear | |
printf "%s\n" "" "Always happy to help you, see you soon." "" | |
printf "%s\n" "" "Made in Nepal by sidbelbase. " "" | |
sleep 4 | |
clear | |
exit 0 | |
} | |
while : | |
do | |
main_menu | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment