Advertisement
TTpocToXaKep

[shitt] Youtube Downloader Tkinter with link

Feb 1st, 2023 (edited)
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # https://pastebin.com/u/TTpocToXaKep
  2. import tkinter as tk
  3. from tkinter import filedialog
  4. import youtube_dl
  5.  
  6. #Create window
  7. root = tk.Tk()
  8.  
  9. #Create function
  10. def download():
  11.     video_url = entry.get()
  12.     save_path = filedialog.asksaveasfilename(defaultextension='.mp4')
  13.    
  14.     #Options for downloading
  15.     ydl_opts = {
  16.         'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
  17.         'outtmpl': save_path
  18.     }
  19.    
  20.     #Download video
  21.     with youtube_dl.YoutubeDL(ydl_opts) as ydl:
  22.         ydl.download([video_url])
  23.  
  24. #Create label
  25. label = tk.Label(root, text="Enter URL")
  26. label.pack(pady=10)
  27.  
  28. #Create entry
  29. entry = tk.Entry(root)
  30. entry.pack(pady=10)
  31.  
  32. #Create Button
  33. button = tk.Button(root, text="Download", command=download)
  34. button.pack()
  35.  
  36. #Keep window open
  37. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement