3 Lines of Code And You Can Download Your Favourite Youtube Video.



Lets Dive Into the code.

  1. Firstly you need to install pytube  using pip install pytube.
  2. You then need to import pytube library
  3. I have used sys library to take input from command line you dont need it
  4. Just replace your url with sys.argv[1]
  5. Please find the sample url https://www.youtube.com/watch?v=Jx5Vn4F0OBc&t=45s
  6. You then need to stream the first video from the object yt
  7. Finally use download method and dowload it to your desktop location
  8. Here I have given my desktop location,you can replace it with yours.
  9. Thats it walla!!!


import pytube
import sys

# replace sys.argv[1] with your youtube link
yt = pytube.YouTube(sys.argv[1])
stream = yt.streams.first()
stream.download("D:/")
print("Video Downloaded")

Comments

Popular posts from this blog

Leetcode Problem(Easy) Roman to Integer

Leetcode : (Find Minimum in Rotated Sorted Array)