Пытаюсь воспроизвести видео с YouTube в виде аудио через бот Discord. Я столкнулся с запрещенной ошибкой 403 и добавил YDL_OPTIONS, чтобы обойти ее. Теперь выдает код ошибки 3436169992. Бот пишет на сервер «сейчас играет: xxxx», но звук не воспроизводится. Есть какие-нибудь подсказки?
FFMPEG_OPTIONS = {
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
"options": "-vn -filter:a \"volume=0.25\""
}
# yt-dlp options
YDL_OPTIONS = {
"format": "bestaudio[ext=webm][acodec=opus]/bestaudio",
"noplaylist": True,
"quiet": True,
"extract_flat": False,
"no_warnings": True,
"source_address": "0.0.0.0" # Prevents YouTube throttling
}
voice_clients = {}
@bot.event
async def on_message(message):
if message.content.startswith("-play"):
try:
# Ensure the user is in a voice channel
if not message.author.voice:
await message.channel.send("You need to be in a voice channel to use this command.")
return
# Connect to the user's voice channel if not already connected
if message.guild.id not in voice_clients or not voice_clients[message.guild.id].is_connected():
voice_client = await message.author.voice.channel.connect()
voice_clients[message.guild.id] = voice_client
else:
voice_client = voice_clients[message.guild.id]
# Extract the YouTube URL from the command
url = message.content.split()[1]
# Download and extract audio using yt-dlp
with YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
audio_url = info["url"]
title = info.get("title", "Unknown Title")
# Debug: Print the extracted audio URL
print(f"Audio URL: {audio_url}")
# Play the audio using FFmpeg
source = FFmpegPCMAudio(audio_url, **FFMPEG_OPTIONS)
voice_client.play(source, after=lambda e: print("Playback finished."))
# Notify the user
await message.channel.send(f"Now playing: {title}")
except Exception as e:
print(f"Error: {e}")
await message.channel.send("An error occurred while trying to play the audio.")
Подробнее здесь: https://stackoverflow.com/questions/793 ... 3436169992
Процесс ffmpeg 20564 успешно завершен с кодом возврата 3436169992 ⇐ Python
Программы на Python
-
Anonymous
1737216501
Anonymous
Пытаюсь воспроизвести видео с YouTube в виде аудио через бот Discord. Я столкнулся с запрещенной ошибкой 403 и добавил YDL_OPTIONS, чтобы обойти ее. Теперь выдает код ошибки 3436169992. Бот пишет на сервер «сейчас играет: xxxx», но звук не воспроизводится. Есть какие-нибудь подсказки?
FFMPEG_OPTIONS = {
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
"options": "-vn -filter:a \"volume=0.25\""
}
# yt-dlp options
YDL_OPTIONS = {
"format": "bestaudio[ext=webm][acodec=opus]/bestaudio",
"noplaylist": True,
"quiet": True,
"extract_flat": False,
"no_warnings": True,
"source_address": "0.0.0.0" # Prevents YouTube throttling
}
voice_clients = {}
@bot.event
async def on_message(message):
if message.content.startswith("-play"):
try:
# Ensure the user is in a voice channel
if not message.author.voice:
await message.channel.send("You need to be in a voice channel to use this command.")
return
# Connect to the user's voice channel if not already connected
if message.guild.id not in voice_clients or not voice_clients[message.guild.id].is_connected():
voice_client = await message.author.voice.channel.connect()
voice_clients[message.guild.id] = voice_client
else:
voice_client = voice_clients[message.guild.id]
# Extract the YouTube URL from the command
url = message.content.split()[1]
# Download and extract audio using yt-dlp
with YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
audio_url = info["url"]
title = info.get("title", "Unknown Title")
# Debug: Print the extracted audio URL
print(f"Audio URL: {audio_url}")
# Play the audio using FFmpeg
source = FFmpegPCMAudio(audio_url, **FFMPEG_OPTIONS)
voice_client.play(source, after=lambda e: print("Playback finished."))
# Notify the user
await message.channel.send(f"Now playing: {title}")
except Exception as e:
print(f"Error: {e}")
await message.channel.send("An error occurred while trying to play the audio.")
Подробнее здесь: [url]https://stackoverflow.com/questions/79367477/ffmpeg-process-20564-successfully-terminated-with-return-code-of-3436169992[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия