问题描述
我使用 python 中的 pytube 制作了 youtube视频下载器。以前它可以正常工作,但在某些时候会出现错误“资产” 。我已经尝试了很多,但无法解决。我也曾尝试搜索错误解决方案,但找不到类似的东西。
这是我的代码
def startDownload(url):
global file_size
path_to_save = askdirectory()
if path_to_save is None:
return
try:
global MaxFileSize,fileSizeInBytes
choice = youtubeChoicesLabel.get()
url=urlField.get()
yt = YouTube(url)
nome = yt.title
if (choice == download_choices[1]):
print("720p video is downloading")
selectVideo = yt.streams.filter(progressive=True,file_extension='mp4').first()
elif (choice == download_choices[2]):
print("144 video is downloading")
selectVideo = yt.streams.filter(progressive=True,file_extension='mp4').last()
selectVideo = yt.streams.filter(only_audio=True).first()
elif (choice == download_choices[0]):
return
fileSizeInBytes = selectVideo.filesize
MaxFileSize = fileSizeInBytes/1024000
MB =str(MaxFileSize)+ "MB"
print("File Size = : {:00.000f}".format (MaxFileSize))
st= selectVideo
yt.register_on_complete_callback(complete_download)
yt.register_on_progress_callback(progress_download)
file_size=st.filesize
st.download(output_path=path_to_save)
except Exception as e:
print(e)
download_choices = ["----Download Type----","Mp4 720p","Mp4 144p",# "Video 3gp","Audio Mp3"]
def btnClicked():
try:
downloadBtn['text'] = "Please wait....."
downloadBtn["bg"] = "red"
downloadBtn["fg"] ="white"
downloadBtn['state']= 'disabled'
url=urlField.get()
if url == '':
showinfo("Message","Please input a url of the video.....")
return
print(url)
thread= Thread(target=startDownload,args=(url,))
thread.start()
except Exception as e:
print(e)
这是我的错误
soham@LAPTOP-FJLV55TK MINGW64 ~
y"python "e:/python projects/YOUTUBE VIDEO DOWNLOADER/YOUTUBE_VIDEO_DOWNLOADER.py
e:/python projects/YOUTUBE VIDEO DOWNLOADER/YOUTUBE_VIDEO_DOWNLOADER.py
https://www.youtube.com/watch?v=rTuxUAuJRyY
'assets'
解决方法
我遇到了同样的问题,并将pytube
更新到当前可用的最新版本。
pip install pytube==10.0.0
或
pip install --upgrade pytube