🎶 A powerful, feature-rich Discord Music Bot built with Python and discord.py, allowing seamless integration with YouTube and Spotify. Created with the assistance of ChatGPT to demonstrate the capabilities of AI-driven development.
to make the user experience better because it is sometimes annoying to have to use only links.
How?
I designed a quick little patch which uses the youtubesearchpython library and a small function that allows you to search and find by words whatever you want on youtube:
from youtubesearchpython import VideosSearch
def search_youtube_video(query):
try:
search = VideosSearch(query, limit=1)
result = search.result()
if result['result']:
video_url = result['result'][0]['link']
return video_url
else:
return None
except Exception as e:
return None
then I modified the conditions of the /play command to have a third condition where if it's not a spotify or youtube link, it searches youtube with whatever you type:
if 'spotify.com' in url:
player = await SpotifySource.from_spotify_url(url, loop=bot.loop)
elif 'youtube.com' in url or 'youtu.be' in url:
player = await YTDLSource.from_url(url, loop=bot.loop, stream=True)
else:
# Patch
search = search_youtube_video(url)
if search != None:
player = await YTDLSource.from_url(search, loop=bot.loop, stream=True)
else:
embed = Messages.error("Could not be found :(")
await interaction.followup.send(embed=embed, ephemeral=True)
return
it works quite well but it's not perfect, it's something I did in a couple of minutes but it's not quite clean, so surely it can be improved to make it cleaner and tidier.
Thank you 🥇
p.s.: I love this music bot because it sounds great, however I found a couple of bugs, if I have time I will fix them and I will make you a pull request :)
Why?
to make the user experience better because it is sometimes annoying to have to use only links.
How?
I designed a quick little patch which uses the youtubesearchpython library and a small function that allows you to search and find by words whatever you want on youtube:
then I modified the conditions of the /play command to have a third condition where if it's not a spotify or youtube link, it searches youtube with whatever you type:
it works quite well but it's not perfect, it's something I did in a couple of minutes but it's not quite clean, so surely it can be improved to make it cleaner and tidier.
Thank you 🥇
p.s.: I love this music bot because it sounds great, however I found a couple of bugs, if I have time I will fix them and I will make you a pull request :)