【发布时间】:2020-10-28 06:34:22
【问题描述】:
我在 python 中使用 pytube 制作了一个 youtube 视频下载器。它以前工作正常,但在某些时候它给出了 "assets" 的错误。我已经尝试了很多,但我无法解决它。我也曾尝试搜索错误解决方案,但找不到类似的东西。
这是我的代码
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'
【问题讨论】:
-
您的代码似乎有一些未定义的对象。你能补充一下这些细节吗?如果您可以包含代码以便任何人都可以运行它并获得相同的结果,那就更好了,请参阅Minimal, Reproducible Example