Когда я пытаюсь воспроизвести аудио с URL-адреса YouTube, он ничего не воспроизводит и выводит:
[2026-02-06 22:11:21,663] {player.py:233} INFO - ffmpeg process 7252 successfully terminated with return code of 3436169992.
в консоль сервера. Что в этом плохого?
@commands.command()
async def play(self, ctx, *, arg):
FFMPEG_OPTIONS = {
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -probesize 200M",
"options": "-vn",
}
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'quiet': True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
# Searches for the video
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
requests.get(arg)
except Exception as e:
print(e)
info = ydl.extract_info(f"ytsearch:{arg}", download=False)["entries"][0]
else:
info = ydl.sanitize_info(ydl.extract_info(arg, download=False))
url = info["url"]
print(url)
thumb = info["thumbnails"][0]["url"]
title = info["title"]
# Finds an available voice client for the bot.
voice = ctx.guild.voice_client
if not voice:
await voice_channel.connect()
voice = ctx.guild.voice_client
await ctx.send(thumb)
await ctx.send(f"Playing {title}")
source = discord.FFmpegPCMAudio(source=source)
voice.play(source)
Подробнее здесь: https://stackoverflow.com/questions/798 ... o-anything