├── requirements.txt ├── LICENSE ├── python_youtube_downloader.py └── README.md /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prateekralhan/Python-based-Youtube-downloader/HEAD/requirements.txt -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Prateek Ralhan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /python_youtube_downloader.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pytube import YouTube, exceptions 3 | from time import time 4 | from tkinter import * 5 | from customtkinter import * 6 | 7 | # Initialize all the settings 8 | set_appearance_mode("System") # Setting the appearance mode to follow by the app: "System", "Light" or "Dark" 9 | set_default_color_theme("blue") # Setting the theme of the app to follow 10 | for i in os.listdir(os.getcwd()): 11 | if i == "youtube_downloads": # If there's already a folder called "youtube_downloads", do not create a new one 12 | break 13 | else: 14 | os.mkdir("youtube_downloads") # If there is no folder called "youtube_downloads", create a new one 15 | 16 | # Download video function 17 | def download_video(entry_field): 18 | try: 19 | start_time = time() 20 | download_location = "youtube_downloads/" 21 | YouTube(entry_field).streams.first().download(download_location) 22 | end_time = time() 23 | 24 | # Showing the download time in a new window 25 | popup = CTk() 26 | popup.title("Download Status") 27 | popup.resizable(False, False) 28 | popup.geometry("200x100") 29 | popup.grid_columnconfigure(0, weight=1) 30 | popup.grid_rowconfigure((0,1), weight=1) 31 | msg = StringVar() 32 | msg.set(f"Download successful!\nTotal time taken: {round(end_time-start_time,3)} seconds") 33 | label = CTkLabel(popup, text=msg.get()) 34 | label.grid(row=0, column=0) 35 | button = CTkButton(popup, text="OK", command=popup.destroy) 36 | button.grid(row=1, column=0) 37 | popup.mainloop() 38 | except exceptions.RegexMatchError: # If there's an invalid link or empty link, show an error message 39 | error = CTk() 40 | error.title("Error") 41 | error.resizable(False, False) 42 | error.geometry("300x100") 43 | error.grid_rowconfigure((0,1), weight=1) 44 | error.grid_columnconfigure(0, weight=1) 45 | error_label = CTkLabel(error, text="Please enter a valid YouTube link") 46 | error_label.grid(row=0, column=0) 47 | button = CTkButton(error, text="OK", command=error.destroy) 48 | button.grid(row=1, column=0) 49 | error.mainloop() 50 | 51 | # Initializing the layout of the app 52 | master = CTk() 53 | master.title("YouTube Downloader") 54 | master.grid_rowconfigure((0,1), weight=1) 55 | master.grid_columnconfigure((0,1), weight=1) 56 | master.geometry("350x150") 57 | master.resizable(False, False) 58 | CTkLabel(master, text="Enter YouTube video URL:").grid(row=0, column=0) 59 | entry = CTkEntry(master) 60 | entry.grid(row=0, column=1) 61 | CTkButton(master, text='Download', command=lambda *args: download_video(entry.get())).grid(row=1, column=0, columnspan=2) 62 | master.mainloop() 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-based YouTube Downloader 2 | [![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![](https://img.shields.io/badge/Prateek-Ralhan-brightgreen.svg?colorB=ff0000)](https://prateekralhan.github.io/) 3 | 4 | A simple GUI built using Tkinter and pytube for downloading videos from YouTube. 5 | 6 | ***NOTE: This is meant to be used for educational purposes only.*** 7 | 8 | ## Dependencies: 9 | 1. [pytube](https://pypi.org/project/pytube/) 10 | > This is an external library and can be installed using the command `pip install pytube`. 11 | 12 | 2. [CustomTkinter](https://github.com/TomSchimansky/CustomTkinter) 13 | > This is an external library and can be installed using the command `pip install customtkinter`. 14 | 15 | 3. [Tkinter](https://docs.python.org/3/library/tkinter.html) 16 | > This library comes bundled with Python! :smile: 17 | 18 | ## Usage: 19 | 1. Clone this repository in your desired directory. 20 | 21 | 2. Run the command: ```python python_youtube_downloader.py``` and a simple GUI will pop-up: 22 |

23 | 24 |

25 | 3. Enter the YouTube Video URL in the text box and click the ***Download*** button. 26 | 27 | 4. It will take some time to download the video depending on the video size, video quality and your network connectivity. The downloader looks for the best possible video quality and downloads that for you. :wink: 28 | 29 | 5. After the download is complete, a dialog with a message will pop-up: 30 |

31 | 32 |

33 | 6. Navigate to the folder ***youtube_downloads*** and you will find your video there in **.mp4** format. Enjoy! 34 | 35 |
NOTE: If you enter an invalid link, the following error message will show up: 36 |

37 | 38 |

39 | 40 | ## Using the .exe 41 | 42 | 1. You can access the exe from [here.](https://drive.google.com/drive/folders/1IXVDs386gNSZpXsGYfieelWrJ-t5Bpha?usp=sharing) 43 | 2. Download the entire folder and navigate to the **dist** folder. 44 | 3. Inside the **python_youtube_downloader** folder, look for ***python_youtube_downloader.exe***. Double-click on it to run the application. 45 |

46 | 47 |

48 | 4. Follow steps *4-7* mentioned in the *Usage* section. 49 | 50 |
51 | 52 | ### NOTE: 53 | If you come across ***pytube.exceptions.RegexMatchError:*** Exception, then please refer to [this](https://github.com/prateekralhan/Python-based-Youtube-downloader/issues/2) issue. 54 | 55 | ###### Raise an issue, if you want any form of help! :smile: 56 | --------------------------------------------------------------------------------