|
| 1 | +import tkinter as tk |
| 2 | +from tkinter import * |
| 3 | +from pytube import * |
| 4 | +from tkinter import messagebox |
| 5 | + |
| 6 | +# from pytube import YouTube |
| 7 | +# from pytube import streams |
| 8 | +# from pytube.streams import Stream |
| 9 | + |
| 10 | +root = tk.Tk() |
| 11 | +root.title('Youtube Downloader') |
| 12 | +root.geometry('500x200') |
| 13 | + |
| 14 | +link_var = StringVar() |
| 15 | +link = link_var.get() |
| 16 | + |
| 17 | +ytb = YouTube |
| 18 | + |
| 19 | +# video = ytb(link) |
| 20 | + |
| 21 | + |
| 22 | +def url(): |
| 23 | + link = link_var.get() |
| 24 | + yt = ytb(link) |
| 25 | + # filter(progressive=True, res=" 1080p", subtype='mp4') |
| 26 | + stream = yt.streams.get_highest_resolution() |
| 27 | + stream.download('C:/Users/abdel/Videos/Youtube') |
| 28 | + link_var.set("") |
| 29 | + messagebox.showinfo(title='Download', message='Done') |
| 30 | + |
| 31 | + |
| 32 | +def info(): |
| 33 | + video = ytb(link) |
| 34 | + |
| 35 | + print(f"Title: \n {video.title} \n ") |
| 36 | + print(f"Description: \n {video.description} \n") |
| 37 | + print(f"Views: \n {video.views} watchers \n ") |
| 38 | + print(f"Rating: \n {video.rating} / 5 \n ") |
| 39 | + print(f"Duration \n{video.length/60} minutes \n ") |
| 40 | + |
| 41 | + |
| 42 | +title = Label(root, text='Youtube Downloader', |
| 43 | + font=('Helvatical bold', 30, 'bold')).pack() |
| 44 | + |
| 45 | +ent = Entry(root, width="50", textvariable=link_var).pack() |
| 46 | + |
| 47 | +info = Button(root, text='Get Info', command=info).pack() |
| 48 | + |
| 49 | +down = Button(root, text='Download', command=url).pack() |
| 50 | + |
| 51 | +l = Label(root, text='By ABDELILAH').pack(side=BOTTOM) |
| 52 | + |
| 53 | +root.mainloop() |
| 54 | + |
| 55 | + |
| 56 | +def finish(): |
| 57 | + print("Download Done") |
| 58 | + |
| 59 | + |
| 60 | +video.register_on_complete_callback(finish()) |
0 commit comments