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
ffmpeginstalled on your server openssh-serverrunning 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 updateandpkg 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_addressReplaceremote_usernameandserver_ip_addresswith 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-dlpis working on your server by typingyt-dlp --version - Download
yt-dlp.shfrom this repo - Edit
yt-dlp.sh. Set up the directory where you want the files to be downloaded - Put
yt-dlp.shinto your server's home directory
- Download
termux-url-openerfrom this repo - Edit
termux-url-opener. Changeipandhostnamevariables to fit in your server's info INFO: Filetermux-url-openershouldn't have any extension - We need to put that script into Termux
/bindirectory. 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 Stickdon't have USB slot, so use ADB instead - In Termux
~home directory, create a bin directory withmkdir bincommand - Put
termux-url-openerin that directory - Type
chmox +x termux-url-openerto 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.