Step by Step Procedure to create Python Youtube video downloader with Pytube
Hello friends how are you, Today in this post "Python Youtube video downloader with Pytube" i am going to teach you how you can create your own Youtube video downloader using only 4 lines of code. Python has very strong collection of libraries that make it very different from other programming languages. Using these libraries we can do a very big task or program with very few lines of code.
If you are a computer science students or teacher and want to learn something interesting in programming then just go through this post. This can also be a simple and interesting project for you.
Now i am going to explain it step by step so just go through this post to understand this completely.
If you want to understand this through video then watch this video i have explained it step by step live
Step 1: Install Python : Click here to watch a video on how to install python or Open any browser and type Download Python and click the first link you will get official website of python here you will get a Download button and after clicking on this button you will get exe of latest python version just install it into your system.
Step 2: Install Pycharm | Create Project | Install Library: Click here to watch a single video on How to install Pycharm | Create Project | Install Library or To install Pycharm IDE Open any browser and type Download Pycharm and click the first link you will get official website of Pycharm here you will get a black download button and after clicking on this button you will get an exe of Pycharm , just install it into your system. If you are facing problem to install then watch the above video i have explained step by step.
Step 3: Create Project : Open Pycharm click on File which is in top left of screen and select New Project. Then you will get a screen. Here first you need to select directory of your project and then type a name for your project like "YoutubeDownloader" after directory name, and at last click the create button to create this project.
Step 4: Create Python file: To create a python file for coding in your project just right click on project name "YoutubeDownloader" and select new and click on Python File , you will get popup screen in which you have to type a name like "Program" for python file and press enter, it will create a python file with name Program.py inside the project YoutubeDownloader.
#import library from pytube import YouTube #access video from url using YouTube() url=YouTube("https://www.youtube.com/watch?v=1DF6sx5qlQc") #download video using downlod() video=url.streams.first().download() #print success message print("video downloaded successfully")
#import library from pytube import YouTube #access video from url using YouTube() url=YouTube("https://www.youtube.com/watch?v=1DF6sx5qlQc") #download video using downlod() video=url.streams.get_audio_only().download() #print success message print("Audio downloaded successfully")
#import library from tkinter import * from pytube import YouTube #creating window root = Tk() #setting width and height of window root.geometry('500x250') #title for window root.title("krazyprogrammers presents") #set background color root["bg"]="#D55B06" #Label for heading Label(root,text = 'Krazy Youtube Video Downloader', font ='arial 18 bold',fg="white",bg="#D55B06").pack() #declaring variable link = StringVar() #label for heading Label(root, text = 'Paste video Link Here:', font = 'arial 15 bold',bg="#D55B06").place(x= 160 , y = 60) #textbox/entrybox for getting link of video link_enter = Entry(root, width = 60,textvariable = link).place(x = 72, y = 90) #function for downloading def YouTubeDownloader(): #applying validation if link.get()!="": #getting url url =YouTube(str(link.get())) video = url.streams.first() #download video video.download() #show messsage Label(root, text = 'Video is downloaded successfully', font = 'arial 15',bg="#D55B06",fg="white").place(x= 70 , y = 210) else: Label(root, text='Link is empty', font='arial 15',bg="#D55B06",fg="white").place(x=180, y=210) #button for download Button(root,text = 'Download', font = 'arial 15 bold' ,bg = 'red',fg="white", padx = 1, command = YouTubeDownloader).place(x=180 ,y = 150) #Run Application root.mainloop()
0 Comments