【发布时间】:2021-07-17 13:32:05
【问题描述】:
我的 pytube 输出路径有问题,当我将 output_path 设置为 C:/Users/%UserProfile%/Desktop 视频停止下载时,代码有什么问题?
import PySimpleGUI as sg
import re
from pytube import YouTube
sg.theme('Dark')
layout = [
[sg.Text('Enter Youtube video link'), sg.InputText()],
[sg.Button('Download'), sg.Button('Cancel')]]
# Create the Window
window = sg.Window('Youtube Downloader', layout)
# Event Loop to process "events" and get the "values" of the inputs
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
break
if re.search(r'\byoutube.com\b', values[0]) or re.search(r'\byoutu.be\b', values[0]):
video = YouTube(values[0])
YouTube(values[0]).streams.filter(res="1080p").first().download(output_path="C:/Users/%UserProfile%/Desktop")
sg.popup('You downloaded: ', video.title)
else:
sg.popup('This is not a Youtube link, please try again ')
window.close()
【问题讨论】:
标签: python python-3.x pytube