无法使用youtube_dl下载文件

问题描述

我正在尝试通过使用discord.py使用ffmpeg和youtube_dl从机器人播放音乐,但似乎无法下载文件

这是我的代码

voice = get(client.voice_clients,guild=ctx.guild)

ydl_opts={
    'format': 'bestaudio/best','noplaylist': 'True','postprocessors': [{
        'key': 'FFmpegExtractAudio','preferredcodec':'mp3','preferredquality':'192',}],}

with youtube_dl.YoutubedL(ydl_opts) as ydl:
    print("Downloading audio Now \n")
    ydl.download([url])

for file in os.listdir("./"):
    if file.endswith(".mp3"):
        name=file
        print(f"Renamed File: {file}\n")
        os.rename(file,"song.mp3")

voice.play(discord.FFmpegPCMAudio('song.mp3'),after=lambda e: print(f"{name} has finished playing"))
voice.is_playing()
voice.source=discord.PCMVolumeTransformer(voice.source)
voice.source.volume= 0.7

nname = name.rsplit("-",2)
await ctx.send(f"Playing {nname}")
print("Playing \n")

似乎什么也没发生,该机器人没有播放任何音乐。

我对此很陌生,有人可以帮忙吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)