Skip to content
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
8 changes: 6 additions & 2 deletions youtubedownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ def download():
url = YouTube(str(url_box.get()))
video = url.streams.first()
filename = filedialog.asksaveasfilename(defaultextension=".mp4", filetypes=[("MP4 files", "*.mp4")])
video.download(filename=filename)
messagebox.showinfo('', 'Download completed!')
if filename: # Check if a filename is selected
video.download(filename=filename)
messagebox.showinfo('', 'Download completed!')
else:
messagebox.showwarning('', 'Download cancelled!')
except Exception as e:
messagebox.showerror("Error", "An error occurred while downloading the video.")



root = Tk()
root.title('YouTube Downloader')
root.geometry('780x500+200+200')
Expand Down