Before publishing this post, I did some searching. It is not illegal to download videos. However, it's only for personal use ONLY. If you are selling the software, that's illegal(or immoral).
Thanks, but I am not able to see that on below terms:
The following restrictions apply to your use of the Service. You are not allowed to:
access, reproduce, download, ....
There is a mixed bag of information on this topic. Some people say it's legal.
And some people say it is not.
If I prefer the ToS then YouTube itself is doing illegal stuff as it offers to make videos offline.
If you ask me is it legal or not, I will say as long as you are not establishing the contents as your own and giving the content creators the proper value, it's not that harmful.
Also, there is no past history of google suing developers for downloading videos(at least I haven't seen one).
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.