YouTube Videos Download Using Python Codes

Use OAuth to access age-restricted videos, and ffmpeg to get high resolution 2160p (4K) videos

Black_Raven (James Ng)
Geek Culture

--

Here’s the Friend Link to read this member-only story.

Skip to sample code: https://github.com/JNYH/pytube/blob/master/pytube_sample_code.ipynb

Photo by Rubaitul Azad on Unsplash

Please note that all videos on YouTube are copyrighted. Do not use them for commercial purposes.

I keep some videos that I like in my personal storage, so that I can access them without the need for the internet. There are 2 ways to download my favourite videos from YouTube:

  1. youtube-dl is a command-line utility, callable from any programming language.
  2. pytube is a python library

I have chosen the latter, because it is very simple to use, and I could use additional library to combine the Adaptive Streams to get 4K (2160p) resolution videos!

Thanks to DASH (Dynamic Adaptive Stream over HTTP) which is an adaptive bitrate streaming (ABR) technique that enables high quality streaming of media content over the Internet delivered from conventional HTTP web servers. This method enables the content to dynamically adapt to the viewer’s bandwidth capacity by shifting between high-quality and low-quality video…

--

--