Downloads YouTube videos to your external NAS over SSH.
It uses Termux and URL as a argument, as shown on a video:
Video.mp4
You like that youtube video, and you want to archive it to your local server NAS. You don't want to turn on your PC just to download that one video, instead your TV can do it for you automatically!
I'm using this script to put videos from SmartTube straight into my Jellyfin server, it works perfect for that.
- yt-dlp as well as
ffmpeg
installed on your server openssh-server
running on your server- Termux app installed on your Android TV Client
- SmartTube app or something else that will get the "Share link..." popup
To simplify steps I recommend connecting a keyboard to your Android TV.
- Run
pkg update
andpkg upgrade
- Run
pkg install openssh
We need to be able to connect to our server without providing a password. To do that, we need to generate SSH key pair. In order to do that:
ssh-keygen -C "your_device_name"
Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):
Press EnterEnter passphrase (empty for no passphrase):
Press Enter- Now, we need to upload your key to the server. We can do it with one command:
ssh-copy-id remote_username@server_ip_address
Replaceremote_username
andserver_ip_address
with your data - You will be prompted to enter remote_username password
- SSH passwordless login should be now active on your Termux install
- Confirm that
yt-dlp
is working on your server by typingyt-dlp --version
- Download
yt-dlp.sh
from this repo - Edit
yt-dlp.sh
. Set up the directory where you want the files to be downloaded - Put
yt-dlp.sh
into your server's home directory
- Download
termux-url-opener
from this repo - Edit
termux-url-opener
. Changeip
andhostname
variables to fit in your server's info INFO: Filetermux-url-opener
shouldn't have any extension - We need to put that script into Termux
/bin
directory. The simplest way would be copying the file from your PC into USB drive, then connecting it to your Android TV. However, some devices likeMi TV Stick
don't have USB slot, so use ADB instead - In Termux
~
home directory, create a bin directory withmkdir bin
command - Put
termux-url-opener
in that directory - Type
chmox +x termux-url-opener
to grant executing permissions - All done! Termux should now be configured properly. Press 'Share link' in SmartTube or similiar app, select Termux, and your video should be now downloading to your server over SSH!
It should work as long as it is based on Android, like your Android Phone or Tablet, but it's untested.