0
import pytube
from tkinter import *
import threading

def download1():
    link = test_url.get()

    yt = pytube.YouTube(link)
    videos = yt.get_videos()

    n = quality.get()
    vid = videos[n - 1]

当我尝试线程下载时,我收到一条错误消息,指出 IndexError: list index out of range from vid = videos[n - 1]

    destination = destination_test.get()
    vid.download(destination)

当我尝试在此处线程下载时会发生此问题。

def thread():
    download2 = threading.Thread(target=download1() )
    download2.start()
    download1()


root = Tk()
test_url = StringVar()
quality = IntVar()
destination_test = StringVar()


url_label = Label(text='Enter Url')
quality_label = Label(text='quality')
destination_label = Label(text='Destination')
url_label.grid(row=0, column=0)
quality_label.grid(row=1, column=0)
destination_label.grid(row=2, column=0)
url_entry = Entry(textvariable=test_url)
url_entry.grid(row=0, column=1)
quality_entry = Entry(textvariable=quality)
quality_entry.grid(row=1, column=1)
destination_entry = Entry(textvariable=destination_test)
destination_entry.grid(row=2, column=1)
download = Button(text='download', command=thread())
download.grid(row=3, column=1)

root.mainloop()
4

0 回答 0