Discord Music Bot Issue with Youtube_dl #26505

Open
opened 2026-02-21 14:20:56 -05:00 by deekerman · 0 comments
Owner

Originally created by @Cordometer on GitHub (Jun 28, 2023).

Coding


import discord
from discord.ext import commands
import os
import asyncio
import youtube_dl
import time

client = commands.Bot(command_prefix="?",intents = discord.Intents.all(), case_insensitive=True)
key = "(Token hidden for obvious reasons)"

voice_clients = {}

yt_dl_opts = {'format': 'bestaudio/best'}
ytdl = youtube_dl.YoutubeDL(yt_dl_opts)

ffmpeg_options = {'options': "-vn"}

@client.event
async def on_ready():
print(f"Bot logged in as {client.user}")

@client.event
async def on_message(msg):
if msg.content.startswith("?play"):

    try:
        voice_client = await msg.author.voice.channel.connect()
        voice_clients[voice_client.guild.id] = voice_client
    except:
        print("error")

    try:
        url = msg.content.split()[1]

        loop = asyncio.get_event_loop()
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))

        song = data['url']
        player = discord.FFmpegPCMAudio(song, **ffmpeg_options)

        voice_clients[msg.guild.id].play(player)

    except Exception as err:
        print(err)


if msg.content.startswith("?pause"):
    try:
        voice_clients[msg.guild.id].pause()
    except Exception as err:
        print(err)

if msg.content.startswith("?resume"):
    try:
        voice_clients[msg.guild.id].resume()
    except Exception as err:
        print(err)

if msg.content.startswith("?stop"):
    try:
        voice_clients[msg.guild.id].stop()
        await voice_clients[msg.guild.id].disconnect()
    except Exception as err:
        print(err)

My problem


So I am new to coding and I been working on a problem for a couple hours now. The issue that I am having is that I get an error that says that the uploader id is unable to be extracted. I do not know exactly the solution is but I been trying out different things like "sudo apt-get remove -y youtube-dl" and "sudo pip install -U youtube-dl" to try figure this problem out. I usually end up with "The term 'sudo' is not recognized as the name of a cmdlet, function, script file, or operable program."

Here is the full error message of what comes up when I try and get it working:

"ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output."

Anyone, by chance, got an answer to this? I been looking all over for a fair bit now

Originally created by @Cordometer on GitHub (Jun 28, 2023). Coding **************************** import discord from discord.ext import commands import os import asyncio import youtube_dl import time client = commands.Bot(command_prefix="?",intents = discord.Intents.all(), case_insensitive=True) key = "(Token hidden for obvious reasons)" voice_clients = {} yt_dl_opts = {'format': 'bestaudio/best'} ytdl = youtube_dl.YoutubeDL(yt_dl_opts) ffmpeg_options = {'options': "-vn"} @client.event async def on_ready(): print(f"Bot logged in as {client.user}") @client.event async def on_message(msg): if msg.content.startswith("?play"): try: voice_client = await msg.author.voice.channel.connect() voice_clients[voice_client.guild.id] = voice_client except: print("error") try: url = msg.content.split()[1] loop = asyncio.get_event_loop() data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False)) song = data['url'] player = discord.FFmpegPCMAudio(song, **ffmpeg_options) voice_clients[msg.guild.id].play(player) except Exception as err: print(err) if msg.content.startswith("?pause"): try: voice_clients[msg.guild.id].pause() except Exception as err: print(err) if msg.content.startswith("?resume"): try: voice_clients[msg.guild.id].resume() except Exception as err: print(err) if msg.content.startswith("?stop"): try: voice_clients[msg.guild.id].stop() await voice_clients[msg.guild.id].disconnect() except Exception as err: print(err) **************************** My problem **************************** So I am new to coding and I been working on a problem for a couple hours now. The issue that I am having is that I get an error that says that the uploader id is unable to be extracted. I do not know exactly the solution is but I been trying out different things like "sudo apt-get remove -y youtube-dl" and "sudo pip install -U youtube-dl" to try figure this problem out. I usually end up with "The term 'sudo' is not recognized as the name of a cmdlet, function, script file, or operable program." Here is the full error message of what comes up when I try and get it working: "ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output." Anyone, by chance, got an answer to this? I been looking all over for a fair bit now
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#26505
No description provided.