This project includes a Python script that utilizes the pytube
library to download videos from YouTube through the command line, displaying the download progress. For Windows users, a Batch file is provided to simplify usage by allowing video links to be inputted directly after a double-click on the file.
- Python 3.x
pytube
library, installable via pip: pip install pytube
- ytdl.py: The Python script for downloading YouTube videos.
- download_youtube_video.bat: For Windows users, a Batch file to run the script with a simple UI for link input.
- Clone or download the repository to your machine.
- Install Python and the
pytube
library if you haven't already. - Place
ytdl.py
anddownload_youtube_video.bat
in your preferred download directory.
- Edit
download_youtube_video.bat
by right-clicking and selecting "Edit". ReplaceC:\path\to\ytdl.py
with the full path to whereytdl.py
is saved. - Save and close the editor.
- Double-click
download_youtube_video.bat
, input the YouTube video link when prompted, and press Enter. - The video will be downloaded to the directory specified in
ytdl.py
, with progress shown in the command window.
- Open a terminal or command prompt.
- Navigate to the directory containing
ytdl.py
. - Execute the script with the YouTube video URL as an argument:
python ytdl.py "https://www.youtube.com/watch?v=VIDEO_ID"
Replace VIDEO_ID with the actual YouTube video ID.
Customizing Download Location
To change where videos are downloaded, edit the ytdl.py script and modify the path in the yd.download('/path/to/directory') function to your desired location.
Notes
Downloads the highest available resolution of the video.
Shows download progress in the command line.
Troubleshooting
If there are issues with pytube, ensure you have the latest version installed. PyTube is frequently updated to fix bugs and issues.
Contributing
Contributions to improve the script or fix issues are welcome. Please fork the repository and submit a pull request with your changes.