質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

1041閲覧

Discord.pyでボイスチャンネルにYoutubeの音源を流したい

Zora

総合スコア20

Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2022/05/02 11:17

前提

Discord.pyでYoutubeの音源を流すBOTを作っています。
他のコードなどはありません。

実現したいこと

DiscordのボイスチャンネルでYoutubeの音源を流す

発生している問題・エラーメッセージ

error

1ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one. 2Ignoring exception in command play: 3Traceback (most recent call last): 4 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2115, in post_process 5 files_to_delete, info = pp.run(info) 6 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 275, in run 7 filecodec = self.get_audio_codec(path) 8 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 166, in get_audio_codec 9 raise PostProcessingError('ffprobe/avprobe and ffmpeg/avconv not found. Please install one.') 10youtube_dl.utils.PostProcessingError: ffprobe/avprobe and ffmpeg/avconv not found. Please install one. 11 12During handling of the above exception, another exception occurred: 13 14Traceback (most recent call last): 15 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped 16 ret = await coro(*args, **kwargs) 17 File "main.py", line 32, in play 18 ydl.download([url]) 19 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2068, in download 20 res = self.extract_info( 21 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info 22 return self.__extract_info(url, ie, download, extra_info, process) 23 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper 24 return func(self, *args, **kwargs) 25 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 847, in __extract_info 26 return self.process_ie_result(ie_result, download, extra_info) 27 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 881, in process_ie_result 28 return self.process_video_result(ie_result, download=download) 29 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 1692, in process_video_result 30 self.process_info(new_info) 31 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2050, in process_info 32 self.post_process(filename, info_dict) 33 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2117, in post_process 34 self.report_error(e.msg) 35 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 628, in report_error 36 self.trouble(error_message, tb) 37 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 598, in trouble 38 raise DownloadError(message, exc_info) 39youtube_dl.utils.DownloadError: ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one. 40 41The above exception was the direct cause of the following exception: 42 43Traceback (most recent call last): 44 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke 45 await ctx.command.invoke(ctx) 46 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke 47 await injected(*ctx.args, **ctx.kwargs) 48 File "/home/runner/ZoraBOT/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped 49 raise CommandInvokeError(exc) from exc 50discord.ext.commands.errors.CommandInvokeError: Command raised an exception: DownloadError: ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.

該当のソースコード

py

1import discord 2from discord.ext import commands 3import youtube_dl 4import os 5import ffmpeg 6 7client = commands.Bot(command_prefix="!") 8 9@client.command() 10async def play(ctx, url : str): 11 song_there = os.path.isfile("song.mp3") 12 try: 13 if song_there: 14 os.remove("song.mp3") 15 except PermissionError: 16 await ctx.send("Wait for the current playing music to end or use the 'stop' command") 17 return 18 19 voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='General') 20 await voiceChannel.connect() 21 voice = discord.utils.get(client.voice_clients, guild=ctx.guild) 22 23 ydl_opts = { 24 'format': 'bestaudio/best', 25 'postprocessors': [{ 26 'key': 'FFmpegExtractAudio', 27 'preferredcodec': 'mp3', 28 'preferredquality': '192', 29 }], 30 } 31 with youtube_dl.YoutubeDL(ydl_opts) as ydl: 32 ydl.download([url]) 33 for file in os.listdir("./"): 34 if file.endswith(".mp3"): 35 os.rename(file, "song.mp3") 36 voice.play(discord.FFmpegPCMAudio("song.mp3")) 37 38 39@client.command() 40async def leave(ctx): 41 voice = discord.utils.get(client.voice_clients, guild=ctx.guild) 42 if voice.is_connected(): 43 await voice.disconnect() 44 else: 45 await ctx.send("The bot is not connected to a voice channel.") 46 47 48@client.command() 49async def pause(ctx): 50 voice = discord.utils.get(client.voice_clients, guild=ctx.guild) 51 if voice.is_playing(): 52 voice.pause() 53 else: 54 await ctx.send("Currently no audio is playing.") 55 56 57@client.command() 58async def resume(ctx): 59 voice = discord.utils.get(client.voice_clients, guild=ctx.guild) 60 if voice.is_paused(): 61 voice.resume() 62 else: 63 await ctx.send("The audio is not paused.") 64 65 66@client.command() 67async def stop(ctx): 68 voice = discord.utils.get(client.voice_clients, guild=ctx.guild) 69 voice.stop() 70 71 72client.run("TOKEN")

試したこと

エラーメッセージなどを調べ、その対処法を色々試した

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

一緒にBOTを制作している方からコードを頂いたので解決しました
その方の希望によりコードの公開は控えさせていただきます

投稿2022/05/07 01:23

Zora

総合スコア20

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問