-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
|
|
||
|  |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| link_enter = 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() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Entry function doesn't have any return value , why are you assigning it to a variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
Thank you :)