Add Youtube-dl to Termux in Android

Add Youtube-dl to Termux in Android

Install Termux from the Play store.

In termux:

apt update && apt upgrade

Give termux access to your phone’s filesystem via ~/storage/shared :


Install python:

packages install python

Install youtube-dl

pip install youtube-dl

Create a folder to store your downloaded videos:

mkdir /data/data/com.termux/files/home/storage/shared/Youtube

Create youtube-dl config (volume-down key emulates Ctrl in termux):

mkdir -p ~/.config/youtube-dl
nano ~/.config/youtube-dl/config

The contents of my config is as follows:

-o /data/data/com.termux/files/home/storage/shared/Youtube/%(title)s.%(ext)s
-f "best[height<=480]"

(the height<=480 tells youtube-dl to download the best quality version up to 480px in height. You can change to 240, 360, 720 or 1080, etc to suit your needs / bandwidth restrictions.

Save with “Volume-down” + O, then close nano with “Vol-down” + X

Create “termux-url-opener” in ~/bin to enable one-click download via the “Share” menu in the youtube app:

mkdir ~/bin
cd ~/bin
nano termux-url-opener

In that file, place:

youtube-dl $1

Save with “Volume-down” + O, then close nano with “Vol-down” + X

Now when you want to download a youtube video from within the Youtube app, click the “Share” link under the video, and choose “Termux”. The download will start and will be available in the “Youtube” folder in the root of your internal storage.


Comments are closed.