Download Any Videos on the Internet with Android Terminal.
There are many online websites and Android apps that allow you to download videos from the internet. But how about doing it using Android terminal (no ROOT required). Sounds weird? Well, let’s see how to do it.
Related: 3 Ways to Loop YouTube Videos on Android and iOS
Benefits
- No need to leave the YouTube app or any other app for that matter.
- No need to download third-party apps filled with ads.
- Customize once and forget forever.
Disadvantages
- It takes a little tinkering with the Android terminal.
- You don’t have multiple download options (360p or 480, etc.) like in other apps.
So how will this work?
Let’s say you are watching any video in the YouTube app and want to download it. Just click on the Share icon in the upper right corner. Select termux app. This will launch a terminal emulator and execute some commands. That’s it, your video is uploaded to the folder of the YouTube file manager.
This method supports about 1250 sites, including all popular video sites – YouTube, Vimeo, Facebook, twitch, etc. You can check the full list on the YouTube-dl Supported Sites page.
I highly recommend you watch the following video first, in this post I will explain the steps and fix some common errors that can occur when using the method. So let’s get started, okay?
Download any videos online with Android Terminal
Step 1
Go to the Google Play Store and download any terminal emulator app. In this case, let’s move on to Termux.
Step 2
Now, since this is our first setup, we need to enter a few terminal commands. D don’t worry, these commands are all simple. And does not require root access. You can download this file (google drive) and copy them one by one to your terminal.
If you’ve ever worked in the terminal, then you probably know is always good to update your repository. So enter
suitable update and suitable update
and then press Y to confirm your changes.
(Note: If you get the error apt-get: not found , please scroll to the end, I have all the solutions there)
Step 3
Then you need to give ive termux access to your device’s filesystem, so type the following command and press Enter.
Termux-setup-storage
Step 4
Then we need to install the YouTube-dl package, it will do all the magic in the background. But YouTube-dl requires python to work. So, first you need to install python.
packages install python
and then press Y to confirm your changes.
Fifth step
Ok, now we are ready to install YouTube-dl
pip install youtube-dl
Step 6
Now, even if you have YouTube-dl, you still have to report it, w here to save all uploaded videos. And what permission to download. So, first, let’s create a folder to store the downloaded videos.
mkdir /data/data/com.termux/files/home/storage/shared/Youtube
Now, if you go to the root of your internal storage, you should see a folder called YouTube.
Step 7
Now let’s get back to the terminal. We must tell YouTube-dl: “Every time I upload a YouTube video, it must have this name by default and this resolutionâ€
And for this we will create configuration files and add all the rules to them. So, to create a config file. Enter this command.
mkdir -p ~ / .config / youtube-dl .
Step 8
Now, to add rules to this config file, we need some kind of terminal editor. You just can’t write things like you normally do. So, install the nano text editor with the following command
apt-get install nano
Step 9
Ok, now we are adding rules to the config file. Open it in nano editor with this command.
nano ~ / .config / youtube-dl / config
Step 10
And copy and paste the following rules i .e. what is the default download folder, name and resolution. In this case, I chose 480p, which obviously can be changed to 360, 720 or 1080p. If you only want to download audio, use 140, more on that at the end of this article.
No-mtime
-o /data/data/com.termux/files/home/storage/shared/Youtube/%(title)s.%(ext)s
-f “best [height <= 480]”
Now, as a rule, to save the changes we press CTRL + S to the right. But since then we have no CTRL key on Android. These terminal emulators use the volume down key as the CTRL key. So save your changes and exit the application, click using the following command.
Volume Down + O to save changes and press Enter. Then close nano by pressing Vol-down + X
Step 11
Okay, now back in the editor. There is one more thing you need to do: i .e. linking the Youtube-dl terminal command to the Youtube share menu or (any application if it matters)
Again, we need to create a file and add rules to it. J just like we did in the previous step. So enter this command
mkdir ~ / bin
cd ~ / bin
nano termux-url-opener
Step 12
So, we have created a bin folder, and in it we have created a new file called termux-url-opener. T it will open nano editor, paste the following command in it.
youtube-dl $ 1
Save by pressing Volume Down + O, press Enter and then close nano by pressing Volume Down + X
Now, let’s test it
Open the YouTube app (remember that it works for any app if you have the option to share), click the Share link under the video and select Termux. The download will start and complete. You can find it in the YouTube folder.
Common problems and their solutions
1. “apt-get” command not found, did you mean: “apt-get” command from “apt” package
You are most likely typing Apt-get instead of apt-get. Most keyboard applications use the first letter with a capital letter. Terminal is case sensitive
2. mkdir: Unable to create directory “/data/data/com.termux/files/home/storage/shared/Youtube”: no such file or directory.
Either you already have a folder named YouTube in your internal repository, or you haven’t provided the repository access to termux as expected. Make sure you are not using any screen overlay applications like screen recorder or Deskdock, etc. If so, temporarily disable them and rewrite the storage access code like termux-setup-storage
3. What are the codes for downloading audio. Thanks to YouTube user Gaby Tipley for the tip. If you only want to download audio, replace “best [height <= 480]” with 140 so that in the final you have – f 140 instead of -f “best [height <= 480]. I tried it and it worked. 4. How to get pop-ups with different upload formats like 360, 480, 720p, etc. like in YouTube downloader app? We are still working on it. With good codes, this is possible. But, unfortunately, because of the busy schedule, I cannot devote time to it. If you have an idea, please email me or leave a comment below.
On the subject: How much money do youtubers make? Youtubers answer