@bot.on_message(filters.command('song'))
def songs(_,message):
msg = message.text.replace(message.text.split(' ')[0], '')
videosSearch = VideosSearch(msg , limit = 1)
f = videosSearch.result()
nani = f['result']
for link in nani:
url = link['link']
video = pafy.new(url)
audiostreams = video.audiostreams
best = video.getbestaudio()
ad = best.download()
file = open(ad, 'wb')
bot.send_document(message.chat.id, file)
file.close()
我找不到错误,请帮忙
文件=打开(ad“wb”) TypeError:应为str、bytes或os.PathLike对象,而不是NoneType
由于其他两个答复并没有真正解决问题,我将在这里插手
在这些方面:
将
best.download()
的结果分配给ad
,您希望将其与焦图一起发送。由于在open()
上得到一个TypeError,很明显open()
没有得到它所期望的类型,即NoneType
。您必须确保下载了某些内容,并且该方法返回一个您可以使用的值也许可以尝试穴居人的方法,在尝试之前使用
print(ad)
除此之外:Pyrogram不支持发送文件表示(
open()
)。您可以以字节模式打开文件,读取字节并将其与BytesIO一起使用,但是当您的系统上有一个实际文件时,您可以只使用文件的路径:app.send_document(chat_id, "my_file.webm")
请参阅^{} 的文档
替换此项:
为此:
相关问题 更多 >
编程相关推荐