Skip to content

Commit 888f5db

Browse files
authored
Merge pull request larymak#328 from adityajai25/new
Youtube video downloader using python
2 parents d0bfda8 + fbe0188 commit 888f5db

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Pytube is a lightweight and dependency-free Python library designed for fetching videos from the internet. It simplifies the process of downloading videos, particularly from YouTube. However, it's important to note that the actual library isn't named "pytube" but must be installed under that name for usage. Below, you'll find instructions for installing pytube and some guidance on how to utilize it.
2+
3+
Installation:
4+
5+
To install pytube via pip, follow these steps:
6+
7+
Open your command prompt or terminal as an administrator.
8+
Execute the following command:
9+
bash
10+
Copy code
11+
```BASH
12+
pip install pytube
13+
```
14+
This command will download and install pytube along with its dependencies.
15+
16+
Functionality:
17+
18+
Pytube enhances the ease of video downloads by providing a straightforward interface. Here's a general outline of how it works:
19+
20+
Import pytube: Begin by importing the pytube library into your Python script.
21+
22+
Create a YouTube Object: Construct a YouTube object by passing the URL of the video you want to download as a parameter. This object will serve as your entry point for accessing video information and initiating downloads.
23+
24+
Retrieve Video Details: Use the YouTube object to gather information about the video, such as its available resolutions and file extensions. This step allows you to choose the quality and format of the downloaded video.
25+
26+
Download the Video: Finally, download the video by invoking the appropriate method provided by the YouTube object. You have the option to specify a custom name for the downloaded file if you prefer; otherwise, the original filename will be used.
27+
28+
Now, you can proceed with writing and implementing your Python code to download your favorite videos from YouTube using the pytube library. This library streamlines the process and makes it convenient to fetch videos from the internet
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pytube import YouTube
2+
3+
def Download(link):
4+
youtubeObject = YouTube(link)
5+
youtubeObject = youtubeObject.streams.get_highest_resolution()
6+
try:
7+
youtubeObject.download()
8+
except:
9+
print("An error has occurred")
10+
print("Download is completed successfully")
11+
12+
13+
link = input("Enter the YouTube video URL: ")
14+
Download(link)

0 commit comments

Comments
 (0)