import os
import tkinter as tk
from tkinter import *
from threading import *
import threading
import tkinter.messagebox
import sys
from you_get import common as you_get
import time
nMaxThread = 4
ThreadLock = BoundedSemaphore(nMaxThread)
def Download():
url=en1.get()
directory=en2.get()
if re.match(r'^https?:/{2}\w.+$',url) and directory != '':
try:
sys.argv = ['you-get','-o',directory,url]
for i in range(4):
ThreadLock.acquire()
t=threading.Thread(target=you_get.main(),args=())
t=setDaemon(True)
t.start()
tk.messagebox.showinfo(message="下载完成")
except:
time.sleep(0.01)
tk.messagebox.showerror(message="下载失败")
finally:
ThreadLock.release()
else:
tk.messagebox.showerror(message="下载失败")
def CreateSaveFile():
filedir="E:\\bilibili视频\\"
if not os.path.exists(filedir):
os.mkdir(filedir)
root=tk.Tk()
root.title('bilibili的视频下载器')
root["height"]=150
root["width"]=380
root.resizable(0,0)
lal=tk.Label(root,text="欢迎使用bilibili的视频下载器")
lal.place(x=90,y=15,width=200,height=50)
lal=tk.Label(root,text="视频链接")
lal.place(x=10,y=70,height=15)
en1=tk.Entry(root,justify=LEFT,state=NORMAL)
en1.place(x=75,y=70,width=230,height=15)
lal=tk.Label(root,text="存放路径")
lal.place(x=10,y=100,height=15)
entry_var1 = tk.StringVar()
entry_var1.set('E:\\bilibili视频\\')
en2=tk.Entry(root,textvariable=entry_var1,justify=LEFT,state=NORMAL)
en2.place(x=75,y=100,width=230,height=15)
b3=tk.Button(root,text="下载",command=Download)
b3.place(x=320,y=70,width=45,height=45)
CreateSaveFile()
root.mainloop()