diff --git a/cogs/music.py b/cogs/music.py index b599e7a..872e327 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -56,12 +56,22 @@ class VoiceState: self.current = None async def audio_player_task(self): + fmt = "" while True: - if self.playing or self.songs.peek() is None: + if self.playing: + await asyncio.sleep(1) + continue + song = self.songs.peek() + if song is None: await asyncio.sleep(1) continue - self.current = await self.songs.get_next_entry() + try: + self.current = await self.songs.get_next_entry() + await self.current.channel.send("Now playing {}".format()) + except ExtractionError as e: + await song.channel.send("Failed to download {}!\nError: {}".format(self.current.title, e)) + continue source = FFmpegPCMAudio( self.current.filename, diff --git a/cogs/voice_utilities/entry.py b/cogs/voice_utilities/entry.py index 1acaee3..b86cdc7 100644 --- a/cogs/voice_utilities/entry.py +++ b/cogs/voice_utilities/entry.py @@ -92,16 +92,18 @@ class BasePlaylistEntry: class URLPlaylistEntry(BasePlaylistEntry): - def __init__(self, playlist, url, title, requester, duration=0, expected_filename=None, **meta): + def __init__(self, playlist, url, title, ctx, thumbnail, duration=0, expected_filename=None, **meta): super().__init__() self.playlist = playlist self.url = url self.title = title self.duration = duration + self.thumbnail = thumbnail self.expected_filename = expected_filename self.meta = meta - self.requester = requester + self.requester = ctx.message.author + self.channel = ctx.message.channel self.download_folder = self.playlist.downloader.download_folder def __str__(self): diff --git a/cogs/voice_utilities/playlist.py b/cogs/voice_utilities/playlist.py index 19a193d..8310160 100644 --- a/cogs/voice_utilities/playlist.py +++ b/cogs/voice_utilities/playlist.py @@ -37,7 +37,7 @@ class Playlist(EventEmitter): else: return 0 - async def add_entry(self, song_url, requester, **meta): + async def add_entry(self, song_url, ctx, **meta): """ Validates and adds a song_url to be played. This does not start the download of the song. @@ -97,7 +97,8 @@ class Playlist(EventEmitter): self, song_url, info.get('title', 'Untitled'), - requester, + ctx, + info.get('thumbnail', None), info.get('duration', 0) or 0, self.downloader.ytdl.prepare_filename(info), **meta