in a very term, if you make sure the downloaded YouTube videos are only for personal use, not for enterprise, you don’t must put far too much tension around the word “illegal”.
Resolution Options: YT Saver https://savefromx.net/download-youtube-videos/