How to use Termux to download YouTube videos

Last week, we showed you how to download any video from Android terminal without using any third-party software. But there were two major issues that were stopping people from trying it.

  1. You would have to type dozen of commands, and many of you get an error messages while doing that.
  2. There was no option to download videos in multiple formats like 240. 360, or audio file etc.

And finally, thanks to Gabi Tiplea, we have a simple solution. All you have to do is, type in 4 commands in your Termux app and this time it’ll give you options to download different format.

This method support around 1250 sites including all the popular video sites – YouTube, Vimeo, Facebook, twitch etc. You can check out the complete list on YouTube-dl supported sites page.

Download Any Video on Android Without Any Third-Party App (Video)

Follow the steps

1. Go to play store and download the termux app. If you tried the previous tutorial on termux, then uninstall the termux app and reinstall it.

2. Next, open the termux app and copy paste the 4 commands in the same order. Just copy paste them it will run som commands to download the library.

wget -O


chmod u+x


3. When prompt, you will have to tap OK, to allow termux access to your storage. And after running few more command, it’ll be all done.

4. And that’s it. Now, if you go to any video sites that is supported by YouTube-dl and then tap on share button > Select termux app > select any format by typing the number corresponding to it. And there we go.

5. The downloaded file will be available on your YouTube folder in the root of internal storage.

So, what really changed?

Instead of typing the code one by one like the last time (link above) we have grouped them together in a Pastebin file. And in the current setup, we are using Wget to download that Pastebin file and installing it.

In future, if you guys need any feature request, just shoot us an email and we can simply update the paste bin.


If you are getting the errors like – http or ftp url not found.

1. It is very important to uninstall termux and install it again, that’s the key.

2. Then update with apt update && apt -y upgrade.

3. Next, give termux access to your storage, termux-setup-storage (this one is optional, I don’t know if it’s working because of this or because of the other steps above, but it’s better to be sure)

4. Then type the 4 commands in the same order.

Here is the Pastebin code for all those who are interested.

# 4/05/2017 Gabi Tiplea

echo -e "Updating default packages\n"
apt update && apt -y upgrade

echo -e "Requesting acces to storage\n"
sleep 5

echo -e "Installing python\n"
packages install -y python

echo -e "Installing youtube-dl\n"
yes | pip install youtube-dl

echo -e "Creating the Youtube folder to download the files\n"
mkdir ~/storage/shared/Youtube

echo -e "Creating youtube-dl folder for config\n"
mkdir -p ~/.config/youtube-dl

echo -e "Creating bin folder\n"
mkdir ~/bin

echo -e "Downloading and installing termux-url-opener\n"
wget -O ~/bin/termux-url-opener
dos2unix ~/bin/termux-url-opener

echo -e "\n"
echo -e "Copyright 2017 Gabi Tiplea\n"

Second code

# Copyright 2017 Gabi Tiplea

echo "Copyright 2017 Gabi Tiplea"
echo "For audio only press 1"
echo "For video 360p press 2"
echo "For video 480p press 3"
echo "For video 720p press 4"
echo "For video 1080p press 5"

command='-no-mtime -o /data/data/com.termux/files/home/storage/shared/Youtube/%(title)s.%(ext)s -f'
read option

if [ "$option" -eq "1" ]
    echo "$command 140" > ~/.config/youtube-dl/config
    youtube-dl $1

elif [ "$option" -eq "2" ]
    echo "$command \"best[height<=360]\"" > ~/.config/youtube-dl/config
    youtube-dl $1

elif [ "$option" -eq "3" ]
    echo "$command \"best[height<=480]\"" > ~/.config/youtube-dl/config
    youtube-dl $1

elif [ "$option" -eq "4" ]
    echo "$command \"best[height<=720]\"" > ~/.config/youtube-dl/config
    youtube-dl $1

elif [ "$option" -eq "5" ]
    echo "$command \"best[height<=1080]\"" > ~/.config/youtube-dl/config
    youtube-dl $1


About Mrinal Saha

Mrinal is a tech geek who spends half of his day reading and writing about tech. While the nights are spent on shooting or editing YouTube videos. Feel free to geek out with him on-