Trouble Switching Audio Sources #7389
Unanswered
mrracoonman
asked this question in
Q&A
Replies: 1 comment 5 replies
-
You can use youtube_dl https://pypi.org/project/youtube_dl/ from youtube_dl import YoutubeDL
with YoutubeDL({"format": "bestaudio", "quiet": True}) as ydl:
info = ydl.extract_info("https://youtu.be/dQw4w9WgXcQ", download = False) and then when you use FFmpegPCMAudio, enter please note this is extremely simplified and will probably need a lot more to function correctly, but this should be the basics. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a decent working discord music bot, but it runs off of pre-downloaded files. I like having a limited selection but I don't want to take up large amounts of space with the amount of files I have. Is there a way to change the audio source from a file location to a YouTube URL without downloading anything?
The code I'm currently working with is as follows:
(I can never figure out the "insert code" thing here in Github, but it is in fact properly indented and has the proper imports. I have no idea why it looks the way it does, I am including lines to help clear thing up.)
@bot.command(aliases=["p", "P", "Play"])
async def play(ctx, *, arg=None):
songData = songs[arg]
audio_source = songData[0]
x = songData[1]
length = songData[2]
image = songData[3]
guild = ctx.guild
voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
And my list of files looks somewhat like this:
songs = {"FIRST SONG IN LIST": [discord.FFmpegPCMAudio(r'FILE LOCATION OF SAID MP3 FILE IN MY COMPUTER'), "DISPLAY NAME FOR THE SONG IN DISCORD", "SONG LENGTH", "URL OF IMAGE I HAVE CHOSEN TO REPRESENT SONG IN DISCORD"]}
Except it is over 50 songs long, with plans to extend it further, and that takes up way too much space.
To recap, I don't want to post a URL in the command when I use my bot, I want a selection from a list I have made. My problem is I haven't found anything that can let me change the audio sources from file locations to YouTube URLs.
I am grateful for any help, let me know if I can clear anything else up.
I am on Windows 10.
Beta Was this translation helpful? Give feedback.
All reactions