from pytube import YouTube
import os
from tkinter import *
root=Tk()
root.geometry('600x200')
root.title('Youtubedan video yuklash | Beta')
root.resizable(False,False)
Label_1=Label(root,text="Video manzilini kiriting...", font=("bold",20))
Label_1.place(x=120,y=20)
Label_2=Label(root, text="YouTubedagi kichik hajmdagi videolarni\nkompyuterga yuklab olish uchun mo`ljallangan dastur\npython dasturlash tilida yaratildi\n</Developer By: Firdavs_dev ", width=80, font=("bold",9))
Label_2.place(x=140,y=150)
mylink = StringVar()
link = Entry(root, width=60, textvariable=mylink)
link.place(x=140, y=80)
l = Label(root, text='')
l.pack(side=TOP)
def downloadVideo():
x = str(mylink.get())
if len(str(x))!=0 and len(str(x))==28 and str(x)[0:16]=='https://youtu.be':
ytvideo = YouTube(x).streams.filter(
progressive=True, file_extension='mp4').order_by('resolution').desc().first()
if not os.path.exists('./YouTubeVideo'):
os.makedirs('./YouTubeVideo')
ytvideo.download('./YouTubeVideo')
l.config(text=str('Video YouTubeVideo papkasiga yuklandi !!!'),bg='green')
else:
l.config(text=str('Error faqat YouTube dagi video linkini kiriting !!!'),bg='red')
Button(root,text="Yuklaw Video", width=20, bg='green',fg="white", command=downloadVideo).place(x=220, y=110)
root.mainloop()
#youtube dan hohlagan videoyizni yuklab beradigan python code