The best and cleanest way is with the small, open-source utility youtube-dl: https://rg3.github.io/youtube-dl/
This is a command-line only tool. Works across all OSs (Windows, macOS, Linux). Read the docs or run youtube-dl --help
to get a list of options (there are many).
But in general you don’t need any of the fancy options, and downloading a video is as easy as running the program from the command line via this simple command:
youtube-dl https://www.youtube.com/whateverURL
The program is constantly updated to keep up with any changes youtube makes to their protocols.