Saturday, January 29, 2022

How to download your Youtube videos using command line

1. Download your version of youtube-dl from https://youtube-dl.org/
2. For Windows 10, download the file https://github.com/ytdl-org/youtube-dl/releases/download/2021.12.17/youtube-dl.exe
3. Copy the file youtube-dl.exe into the d:\youtube-dl\ directory
4. To download a youtube video, open a Windows Powershell and run: 

Examples:
PS D:\youtube-dl> .\youtube-dl.exe https://www.youtube.com/watch?v=pChVWAVY7RU 
PS D:\youtube-dl> .\youtube-dl -o " d:/youtube-dl/Downloads/%(title)s" http://www.youtube.com/watch?v=rnvK2TIhYns


Note:
1. For documentation , please check https://github.com/ytdl-org/youtube-dl/blob/master/README.md
2. For help, run: youtube-dl -h
3. Use the -o option with youtube-dl to manually give a location for the downloaded files:

youtube-dl -o "~/Desktop/%(title)s.%(ext)s" 'youtube file url'
and of course substitute your actual url for 'youtube file url'. This example sends the completed download to your Desktop.

4. Create a configuration file for youtube-dl as follows:

touch ~/.config/youtube-dl.conf
Then set a default download location in this file:

--output "~/Desktop/%(title)s.%(ext)s"
With this in place all downloaded files will automatically go to your Desktop.


From: https://askubuntu.com/questions/373336/where-does-youtube-dl-download-the-videos-to#:~:text=By%20default%20youtube%2Ddl%20downloads,%2C%20there%20is%20%2Df%20option.

#!/bin/sh
answer=""
tput clear
tput cup 05 10
echo "Give the YouTube URL: \c"
# Here you paste the YT-video-URL by ctrl+shift+V
read answer
# The follwing command will display a list of video quality options to choose from
youtube-dl -F $answer
echo
# Here you give the number shown in first column as per your choice
echo "Select Quality (Choose a number): \c"
read qual
# If you don't want to download and quit the shell, give 99
if [ $qual -ne 99 ]
then
youtube-dl -f $qual -o "/home/users/$([System.Environment]::UserName)/Videos/%(title)s.%(ext)s" $answer
else
exit 0
fi

No comments:

Post a Comment