Skip to content

Added YouTube video downloader #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions YouTube-Video-Downloader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# YouTube Video Downloader

The objective of this project is to download any type of video in a fast and easy way from youtube in your device.

In this, user has to copy the youtube video URL that they want to download and simply paste that URL in the ‘paste link here’ section and click on the download button, it will start downloading the video. When video downloading finishes, it shows a message ‘downloaded’ popup on the window below the download button.

</br>

## Prerequisites

To implement this, we use basic concept of python, tkinter and pytube library.

- **Tkinter** is a standard GUI library and it is one of the easiest ways to build a GUI application.
- **pytube** used for downloading videos from youtube

</br>

To install the required modules run pip installer command on the command line:

```
pip install tkinter
pip install pytube
```

</br>

These are the following steps to build:

</br>

### Step 1: Import libraries

Start the project by importing the required modules.

In this script implementation, we import Tkinter and pytube modules.

</br>

### Step 2: Create display window

- **Tk()** used to initialize tkinter to create display window
- **geometry()** used to set the window’s width and height
- **resizable(0,0)** set the fix size of window
- **title()** used to give the title of window
- **Label()** widget use to display text that users can’t able to modify.
- **root** is the name of the window
- **text** which we display the title of the label
- **font** in which our text is written
- **pack** organized widget in block

</br>

### Step 3: Create field to enter link

- **link** is a string type variable that stores the youtube video link that the user enters.
- **Entry()** widget is used when we want to create an input text field.
- **width** sets the width of entry widget
- **textvariable** used to retrieve the value of current text variable to the entry widget
- **place()** use to place the widget at a specific position

</br>

### Step 4: Create function to start downloading

`url` variable gets the youtube link from the link variable by **get()** function and then **str()** will convert the link in string datatype.

The video is downloaded in the first present stream of that video by **stream.first()** method.

**Button()** widget used to display button on the window.

- **text** which we display on the label
- **font** in which the text is written
- **bg** sets the background color
- **command** is used to call the function

**root.mainloop()** is a method that executes when we want to run the program.

</br>

### Output

After running this script, you will be able to see this:

</br>

![YTVD](https://user-images.githubusercontent.com/73488906/111301619-6eeaa100-8678-11eb-9ef2-5ce1b02571cf.png)
28 changes: 28 additions & 0 deletions YouTube-Video-Downloader/youtube_vid_dl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from tkinter import *
from pytube import YouTube

root = Tk()
root.geometry('700x300')
root.resizable(0,0)
root.title("YouTube Video Downloader")

Label(root,text = 'Copy the link of the video you want to download from YouTube', font = 'arial 15 bold').pack()

##enter link
link = StringVar()

Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x = 270 , y = 60)
Entry(root, width = 80,textvariable = link).place(x = 32, y = 90)

#function to download video

def Downloader():

url = YouTube(str(link.get()))
video = url.streams.first()
video.download()
Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x = 270 , y = 210)

Button(root,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'white', padx = 2, command = Downloader).place(x = 280 ,y = 150)

root.mainloop()