0

我想获取视频大小并决定是选择以这个分辨率和大小下载它还是以更大的大小获得更高的分辨率

def download_func():
    try:
        vid = YouTube(link, on_progress_callback=progress_function)
        vid = pafy.new(link)
        streams = vid.streams
        stream = streams[1]
        value = stream.get_filesize()
        print(value)

    except RegexMatchError:
        error_lbl["text"] = "Please enter a video URL!"
        download_btn["state"] = "normal"
        download_btn["bg"] = "red"
        return

    error_lbl["text"] = ""
    vid = vid.streams.get_by_resolution(res_menu_var.get())
    try:
        Thread(target=label, args=(vid,)).start()
        vid.download(path)
    except AttributeError:
        download_btn["state"] = "normal"
        download_btn["bg"] = "red"
        error_lbl["text"] = "Resolution is not available!"
        return
4

0 回答 0