2020-04-16 20:15:37 +02:00
[//]: # "Ctrl+K,V o Ctrl+Shift+V - Para ver vista previa en VSCode"
2020-07-16 00:37:44 +02:00
# Tutorial to install [youtube-dl](https://github.com/ytdl-org/youtube-dl/) in android
2020-06-15 01:47:04 +02:00
2020-07-16 00:37:44 +02:00
Based on < https: / / www . reddit . com / r / Piracy / comments / baufql / youtubedl_the_easy_way_on_android / >
2020-04-16 20:15:37 +02:00
2020-07-16 00:37:44 +02:00
## Usage
2020-06-15 03:07:31 +02:00
Click **Share** , select **Termux** , choose video or audio, and that's it!, it will be saved to `Downloads/{Provider}/` e.g `Downloads/Youtube/`
2020-04-16 20:15:37 +02:00
2020-07-16 00:37:44 +02:00
## Install Termux
2020-04-16 20:15:37 +02:00
2020-07-16 00:37:44 +02:00
< https: / / termux . com / >
## Open Termux and run one of these
2020-04-16 20:15:37 +02:00
2020-11-05 22:27:21 +01:00
<!-- no toc -->
2020-06-15 03:13:04 +02:00
1. [Youtube-dl + sharing + dialog **(Recommended)** ](#youtube-dl--sharing--dialog-recommended )
2. [Youtube-dl + sharing ](#youtube-dl--sharing )
3. [Youtube-dl ](#youtube-dl )
4. [Termux extras ](#termux-extras )
5. [All-In-One ](#all-in-one )
2020-06-15 01:47:04 +02:00
2020-07-16 00:37:44 +02:00
### Youtube-dl + sharing + dialog **(Recommended)**
2020-06-15 01:47:04 +02:00
2020-04-16 20:47:46 +02:00
```bash
# Ask for storage permission
2020-04-16 20:15:37 +02:00
termux-setup-storage & &
2020-04-16 20:47:46 +02:00
# Install youtube-dl
2020-06-26 23:53:59 +02:00
apt update & & apt upgrade -y & & apt install -y python ffmpeg dialog & & pip install youtube-dl & &
2020-06-28 01:31:27 +02:00
# Configure to download videos in `Download/{URL's provider (e.g. Youtube)}/{filename}`
2020-04-16 20:15:37 +02:00
mkdir -p ~/.config/youtube-dl & &
echo "# Default Output Directory and Pattern
2020-06-14 22:32:38 +02:00
-o /data/data/com.termux/files/home/storage/downloads/%(extractor_key)s/%(title).150s-%(id)s.%(ext)s" > ~/.config/youtube-dl/config & &
2020-04-16 20:47:46 +02:00
# Configure to open shared URLs with `youtube-dl {url}`
2020-06-28 01:29:29 +02:00
mkdir -p ~/bin & &
2020-06-13 22:50:03 +02:00
echo '#!/bin/bash
URL=$1
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
CHOICE=$(dialog \
2020-10-16 21:38:04 +02:00
--menu "What would you like to download?" \
2020-06-13 22:50:03 +02:00
$HEIGHT $WIDTH $CHOICE_HEIGHT \
Video "" \
Audio "" \
2>& 1 >/dev/tty)
case $CHOICE in
Video)
2020-09-17 22:59:02 +02:00
echo "Downloading video from $URL"
2020-06-13 22:50:03 +02:00
youtube-dl $URL
;;
Audio)
2020-09-17 22:59:02 +02:00
echo "Downloading audio from $URL"
2020-06-13 22:50:03 +02:00
youtube-dl -x $URL
;;
esac' > ~/bin/termux-url-opener & &
2020-04-16 20:20:47 +02:00
chmod +x ~/bin/termux-url-opener
2020-04-16 20:47:46 +02:00
```
2020-04-16 20:15:37 +02:00
2020-06-28 01:54:11 +02:00
- Paste the script above 🖢 in the Termux console and press < kbd > Enter</ kbd >
- A prompt to enable storage will appear, press < kbd > y</ kbd > then < kbd > Enter</ kbd >
- That's all!, just wait for it to finish upgrading/installing
2020-07-16 00:37:44 +02:00
#### Usage
2020-06-28 01:54:11 +02:00
Share an URL to termux, a dialog will ask you to choose if download **video** or just **audio**
2020-07-16 00:37:44 +02:00
### Youtube-dl + sharing
2020-06-15 03:07:31 +02:00
2020-07-16 00:37:44 +02:00
#### Usage
2020-06-28 01:54:11 +02:00
Share URL to termux, this will automatically download the video.
But if you always want to download just audio, replace `youtube-dl $url` with `youtube-dl -x $url` in the script below 🖣
2020-04-16 20:47:46 +02:00
```bash
2020-06-15 01:47:04 +02:00
# Ask for storage permission
2020-04-16 20:15:37 +02:00
termux-setup-storage & &
2020-06-15 01:47:04 +02:00
# Install youtube-dl
2020-06-26 23:53:59 +02:00
apt update & & apt upgrade -y & & apt install -y python ffmpeg & & pip install youtube-dl & &
2020-06-28 01:31:27 +02:00
# Configure to download videos in `Download/{URL's provider (e.g. Youtube)}/{filename}`
2020-04-16 20:15:37 +02:00
mkdir -p ~/.config/youtube-dl & &
echo "# Default Output Directory and Pattern
2020-06-15 01:47:04 +02:00
-o /data/data/com.termux/files/home/storage/downloads/%(extractor_key)s/%(title).150s-%(id)s.%(ext)s" > ~/.config/youtube-dl/config & &
# Configure to open shared URLs with `youtube-dl {url}`
2020-06-28 01:29:29 +02:00
mkdir -p ~/bin & &
2020-04-16 20:15:37 +02:00
echo "#!/bin/bash
url=$1
youtube-dl $url" > ~/bin/termux-url-opener & &
2020-06-15 01:47:04 +02:00
chmod +x ~/bin/termux-url-opener
```
2020-07-16 00:37:44 +02:00
### Youtube-dl
2020-06-15 03:07:31 +02:00
2020-06-18 22:40:11 +02:00
This will only install youtube-dl in termux, sharing a URL to Termux will not work, you'll need to run the command manually from the terminal, e.g `youtube-dl https://youtu.be/blahblahblah`
2020-06-15 03:07:31 +02:00
```bash
# Ask for storage permission
termux-setup-storage & &
# Install youtube-dl
2020-06-26 23:53:59 +02:00
apt update & & apt upgrade -y & & apt install -y python ffmpeg & & pip install youtube-dl
2020-06-15 03:07:31 +02:00
```
2020-07-16 00:37:44 +02:00
### Termux extras
2020-06-15 01:47:04 +02:00
```bash
# Add special keys to keyboard
# source: https://wiki.termux.com/wiki/Touch_Keyboard#Extra_Keys_Row(s)
2020-06-28 01:29:29 +02:00
mkdir -p ~/.termux
2020-04-16 20:15:37 +02:00
echo "extra-keys = [ \
['ESC', '/', '|', 'HOME', 'UP', 'END', 'PGUP', '-'], \
['TAB','CTRL', 'ALT', 'LEFT', 'DOWN', 'RIGHT', 'PGDN', '~'] \
2020-04-16 20:47:46 +02:00
]" > ~/.termux/termux.properties
2020-06-15 01:47:04 +02:00
# Install nano
2020-06-26 23:53:59 +02:00
apt install -y nano
2020-06-15 03:07:31 +02:00
```
2020-07-16 00:37:44 +02:00
### All-In-One
2020-06-15 03:07:31 +02:00
Youtube-dl + sharing + dialog + Termux extras
```bash
termux-setup-storage & &
2021-02-21 13:14:47 +01:00
apt update & & apt upgrade -y & & apt install -y nano python ffmpeg dialog & & pip install youtube-dl & &
2020-06-15 03:07:31 +02:00
mkdir -p ~/.config/youtube-dl & &
echo "# Default Output Directory and Pattern
-o /data/data/com.termux/files/home/storage/downloads/%(extractor_key)s/%(title).150s-%(id)s.%(ext)s" > ~/.config/youtube-dl/config & &
2020-06-28 01:29:29 +02:00
mkdir -p ~/bin & &
2020-06-15 03:07:31 +02:00
echo '#!/bin/bash
URL=$1
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
CHOICE=$(dialog \
--menu "Que desea descargar?" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
Video "" \
Audio "" \
2>& 1 >/dev/tty)
case $CHOICE in
Video)
youtube-dl $URL
;;
Audio)
youtube-dl -x $URL
;;
esac' > ~/bin/termux-url-opener & &
chmod +x ~/bin/termux-url-opener & &
2020-06-28 01:29:29 +02:00
mkdir -p ~/.termux & &
2020-06-15 03:07:31 +02:00
echo "extra-keys = [ \
['ESC', '/', '|', 'HOME', 'UP', 'END', 'PGUP', '-'], \
['TAB','CTRL', 'ALT', 'LEFT', 'DOWN', 'RIGHT', 'PGDN', '~'] \
]" > ~/.termux/termux.properties
2020-07-16 00:37:44 +02:00
```