Difference between revisions of "YouTube Download Server"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
Line 61: Line 61:


Configure your download server to [[Setting Up OpenVPN & PIA as a client{{!}}'''use a good VPN''']].
Configure your download server to [[Setting Up OpenVPN & PIA as a client{{!}}'''use a good VPN''']].
also:


* <code>sudo apt install mosquitto-clients</code>
* <code>sudo apt install mosquitto-clients</code>
** Handy for integrating the download server into your IoT infrastructure...
Handy for integrating the download server into your IoT infrastructure...


== Usage hints ==
== Usage hints ==

Revision as of 23:50, 20 September 2025

Proven on:
Logo Debian.png
13 (trixie) This includes a lightweight LXC


As always...

Start with:

  • sudo apt update
  • sudo apt upgrade

There are a few good reasons to be set up to download YouTube videos.

  • Geofencing
  • Reliability
  • Bandwidth Management

Fortunately, it's pretty easy to do.

yt-dlp (formerly youtube-dl)

yt-dlp is a pretty awesome tool.

As an added bonus, it also works with a fairly large number of other video sharing sites...

Note: You'll need ffmpeg...

  • sudo apt install ffmpeg

But don't install it through the package manager. It gets incredibly regular updates & the package manager kinda borks this.

Instead, install it directly:

  • sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux -O /usr/local/bin/yt-dlp
  • sudo chmod a+rx /usr/local/bin/yt-dlp

This allows you to regularly update (maybe even through cron) it with the command:

  • sudo yt-dlp -U

Which guarantees you keep up with the multitude of random changes made at YouTube.

Storage

Storage space for downloading (Torrents & such) should be done on a dedicated drive.

I tend to do most of my storage via NFS served up by my dedicated storage server.

Create a DONE & a WIP folder on the storage drive. This will make it easier to keep things organised.

  • sudo mkdir /mnt/Download_Space
  • sudo vi /etc/fstab
StorageServer:/Download_Space /mnt/Download_Space nfs rw,user,exec 0 0
  • sudo mkdir /mnt/Download_Space/YTDL

If you don't want to use an NFS share for this, you could either add a dedicated drive or just set up the folders on the boot drive. I'd seriously recommend, at minimum, 500GB of available space.

Useful things

Configure your download server to use a good VPN.

also:

  • sudo apt install mosquitto-clients

Handy for integrating the download server into your IoT infrastructure...

Usage hints

You can either sign into the machine to download videos, or (especially if you've set up for passwordless SSH) just do it from your desktop.

If you're signed in

  • cd /mnt/Download_Space/YTDL
  • yt_dlp URLofVideoPage

Where URLofVideoPage is simply the URL of the YouTube video (i.e: https://www.youtube.com/watch?v=NkXLP3VtMS8 )

Simple as that, it'll download the video in approximately the best available resolution.

Take a look at yt-dlp --help or visit their instructions online to learn all about possible options.

Remote usage

  • ssh DLSERVER yt_dlp -o "/mnt/Download_Space/YTDL/%(title)s.%(ext)s" URLofVideoPage

Where:

DLSERVER is the name or IP of your download server.

/mnt/Download_Space/YTDL/ Can be any location on that server that you have write access to.

(That whole chunk starting with the -o is like that because the devs forgot to put in a proper "save to" option)

URLofVideoPage is the URL of the YouTube video (i.e: https://www.youtube.com/shorts/c4OdhYWV4Rk )

Yes... This looks complicated... But remember, bash (like most shells) has an alias command.

Scripting

Example of a useful script to update a local copy of a YouTube Channel:

yt-dlp -w --download-archive 11111111-ARCHIVE --write-description -t mp4 -o "%(upload_date)s - %(title)s.%(ext)s" https://www.youtube.com/user/LastWeekTonight

This particular little script maintains a local archive of a channel that YouTube thinks Canadians should not be allowed to watch... (needless to say, it gets run on the VPN equipped Download Server.)

Tips

If you see this error:

ERROR: [youtube] My7MhdGjLzo: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp for how to manually pass cookies. Also see https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies for tips on effectively exporting YouTube cookies

Chances are very good that YouTube hates your VPN exit point.

In my case, they seem to dislike Sweden.

Changing to Ukraine solved the issue... ¯\_(ツ)_/¯

Also... Sidequest... Desktop YT downloading

YoutubeDownloader (Desktop downloader)

Quite functional as long as you don't mind a purely GUI application that can't remember where you really want it to put the files.

Doesn't seem to have any sort of installer...

Just hunt through the folder for the actual application in yer file explorer & double-click it.

It works & isn't particularly hard to use...
For a GUI app, the UI is incrediply limited, but functional enough to get the job done.