added translate interface, needs to fill functionality next
This commit is contained in:
@@ -11,6 +11,11 @@ import yt_dlp
|
||||
|
||||
from cogs.music.help import music_help
|
||||
|
||||
ydl_opts = {
|
||||
'format': 'bestaudio/best',
|
||||
'outtmpl': 'downloads/%(title)s.%(ext)s',
|
||||
}
|
||||
|
||||
class music(commands.Cog):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
@@ -22,6 +27,7 @@ class music(commands.Cog):
|
||||
help_command.cog = self
|
||||
self.help_command = help_command
|
||||
|
||||
|
||||
@commands.command(
|
||||
help="Displays latency from the bot",
|
||||
aliases=['delay'])
|
||||
@@ -49,6 +55,7 @@ class music(commands.Cog):
|
||||
await util.leave_vc(ctx)
|
||||
await ctx.message.add_reaction('👍')
|
||||
|
||||
|
||||
@commands.command(
|
||||
help="Queues a song into the bot",
|
||||
aliases=['p', 'qeue', 'q'])
|
||||
@@ -56,12 +63,9 @@ class music(commands.Cog):
|
||||
if url is None:
|
||||
raise commands.CommandError("Must provide a link or search query")
|
||||
|
||||
|
||||
await util.join_vc(ctx)
|
||||
|
||||
ydl_opts = {
|
||||
'format': 'bestaudio/best',
|
||||
'outtmpl': 'downloads/%(title)s.%(ext)s',
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(url, download=True)
|
||||
@@ -69,5 +73,6 @@ class music(commands.Cog):
|
||||
|
||||
ctx.voice_client.play(discord.FFmpegPCMAudio(executable="ffmpeg", source=filename), after=self.test)
|
||||
|
||||
|
||||
def test(self, error):
|
||||
print("Hello")
|
||||
|
||||
50
cogs/music/translate.py
Normal file
50
cogs/music/translate.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# Handles translating urls and search terms
|
||||
|
||||
def main(url):
|
||||
|
||||
url = url.lower()
|
||||
|
||||
# Check if link or search
|
||||
if url.startswith("https://") is False:
|
||||
return search_song(url)
|
||||
|
||||
#TODO add better regex or something
|
||||
if 'spotify' in url:
|
||||
if 'track' in url:
|
||||
return spotify_song(url)
|
||||
elif 'playlist' in url:
|
||||
return spotify_playlist(url)
|
||||
|
||||
soundcloud_song = 'soundcloud' in url and 'sets' not in url
|
||||
soundcloud_playlist = 'soundcloud' in url and 'sets' in url
|
||||
|
||||
youtube_song = 'watch?v=' in url or 'youtu.be/' in url
|
||||
youtube_playlist = 'playlist?list=' in url
|
||||
|
||||
if soundcloud_song or youtube_song:
|
||||
return song_download(url)
|
||||
|
||||
if youtube_playlist:
|
||||
return playlist_download(url)
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def search_song(search):
|
||||
return None
|
||||
|
||||
|
||||
def spotify_song(url):
|
||||
return None
|
||||
|
||||
|
||||
def spotify_playlist(url):
|
||||
return None
|
||||
|
||||
|
||||
def song_download(url):
|
||||
return None
|
||||
|
||||
|
||||
def playlist_download(url):
|
||||
return None
|
||||
Reference in New Issue
Block a user