问题描述
我正在尝试使用pytube和tkinter在python中创建一个 YouTube视频下载器。大多数视频都可以正常下载,但在某些视频中,我收到的错误代码为“密码” 。发生这种情况时,有人可以帮忙吗?
这是我的代码
'''
#code
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
# video2 = urlField.get()
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("Audio file is downloading")
# selectVideo =yt.streams.get_audio_only()
# new_filename= nome + '*.mp3'
# default_filename= nome + '*.mp4'
# ffmpeg = ('ffmpeg -i ' %path_to_save %default_filename + new_filename)
# subprocess.run(ffmpeg,shell=True)
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))
# yt = YouTube(url)
# st=yt.streams.first()
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)
'''
我也试图以mp3格式下载,但是将'audioonly'属性设置为True会以mp4格式下载我的文件,而没有视频。但我想要mp3中的格式。我该怎么办?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)