2

I am facing a problem "discord.errors.ClientException: ffmpeg was not found." after running the code

import discord, nacl, ffmpeg
from discord import FFmpegPCMAudio
from discord.utils import get
from youtube_dl import YoutubeDL

client = discord.Client()

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    
    if message.content.startswith('&' + 'join'):
        connection = message.author.guild.voice_client
        if (connection):
            await message.channel.send('**Перемещение в** ' + str(message.author.voice.channel))
            await connection.move_to(message.author.voice.channel)
        else:
            await message.channel.send('**Подключение к** ' + str(message.author.voice.channel))
            await message.author.voice.channel.connect()

        ydl_opts = {'format': 'bestaudio', 'noplaylist':'True'}
        FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
        voice = get(client.voice_clients, guild = message.channel.guild)
        video_link = 'https://www.youtube.com/watch?v=uCc7hnuFDmg&ab_channel=Kontor.TV'
        if not voice.is_playing():
            with YoutubeDL(ydl_opts) as ydl:
                info = ydl.extract_info(video_link, download = False)
            URL = info['formats'][0]['url']
            voice.play(FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
            voice.is_playing()
        else:
            await message.channel.send('Музыка уже воспроизводится')
            return

I have tried installing the module pip install ffmpeg. I also downloaded the ffmpeg using this guide: https://www.youtube.com/watch?v=a_KqycyErd8&ab_channel=TroubleChute.

I will be grateful if you can also tell me why the video is being downloaded during the work: [youtube] uCc7hnuFDmg: Downloading webpage [youtube] Downloading just video uCc7hnuFDmg because of --no-playlist

Just the main task is to launch music without downloading.

alxbavy
  • 160
  • 2
  • 11
  • Have you tried the last two suggestions in this issue? https://github.com/Rapptz/discord.py/issues/1072 – Jason Rebelo Neves Feb 20 '21 at 13:10
  • It turns out that all you had to do was restart your computer. But the second question is still relevant. Why and where is the video downloaded while the program is running? – alxbavy Feb 21 '21 at 08:15
  • I believe the way it works by default is to download the video and then extract the audio, but you can change thay by using `postprocessors` as defined in these answers: https://stackoverflow.com/questions/27473526/download-only-audio-from-youtube-video-using-youtube-dl-in-python-script – Jason Rebelo Neves Feb 21 '21 at 10:18
  • I'am sorry. But how can I determine where the files are uploaded to if I am using Python IDLE? – alxbavy Feb 21 '21 at 14:32

0 Answers0