Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://pastebin.com/u/TTpocToXaKep
- import tkinter as tk
- from tkinter import filedialog
- import youtube_dl
- #Create window
- root = tk.Tk()
- #Create function
- def download():
- video_url = entry.get()
- save_path = filedialog.asksaveasfilename(defaultextension='.mp4')
- #Options for downloading
- ydl_opts = {
- 'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
- 'outtmpl': save_path
- }
- #Download video
- with youtube_dl.YoutubeDL(ydl_opts) as ydl:
- ydl.download([video_url])
- #Create label
- label = tk.Label(root, text="Enter URL")
- label.pack(pady=10)
- #Create entry
- entry = tk.Entry(root)
- entry.pack(pady=10)
- #Create Button
- button = tk.Button(root, text="Download", command=download)
- button.pack()
- #Keep window open
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement