From e13f19efb9191dd66d7f34a67b7a19cde531cd4c Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Thu, 30 Dec 2021 20:35:54 -0400 Subject: [PATCH 1/3] Song now represents if it has any problems --- vulkanbot/music/Song.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vulkanbot/music/Song.py b/vulkanbot/music/Song.py index 9ddc478..3fbe61e 100644 --- a/vulkanbot/music/Song.py +++ b/vulkanbot/music/Song.py @@ -11,6 +11,7 @@ class Song(ISong): """Create a song with only the URL to the youtube song""" self.__identifier = identifier self.__info = {} + self.__problematic = False self.__playlist: IPlaylist = playlist def finish_down(self, info: dict) -> None: @@ -54,11 +55,15 @@ class Song(ISong): @property def identifier(self) -> str: return self.__identifier + + @property + def problematic(self) -> bool: + return self.__problematic def destroy(self) -> None: - """Destroy the song from the playlist due to any type of error""" + """Mark this song with problems and removed from the playlist due to any type of error""" + self.__problematic = True self.__playlist.destroy_song(self) - del self def embed(self, title: str) -> Embed: """Configure the embed to show the song information""" From ad05fffa84591b6055410082aea9c56c160fce09 Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Thu, 30 Dec 2021 20:37:09 -0400 Subject: [PATCH 2/3] Music will now wait for the first preload of first song --- vulkanbot/music/Music.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/vulkanbot/music/Music.py b/vulkanbot/music/Music.py index 41368cb..2ad2a18 100644 --- a/vulkanbot/music/Music.py +++ b/vulkanbot/music/Music.py @@ -95,11 +95,27 @@ class Music(commands.Cog): await self.__send_embed(ctx, description=f"Você adicionou {songs_quant} músicas à fila!", colour_name='blue') if not self.__playing: - first = self.__playlist.songs_to_preload[0] - self.__downloader.download_one(first) - first_song = self.__playlist.next_song() + try_another = True + + while try_another: + first = self.__playlist.next_song() + if first == None: + await self.__send_embed(ctx, description='Houve um problema no download dessa música, tente novamente', colour_name='blue') + break + + while True: + if first.source != None: # If song got downloaded + try_another = False + break - await self.__play_music(ctx, first_song) + if first.problematic: # If song got any error, try another one + break + + else: # The song is downloading, checking another time + continue + + if first != None: + await self.__play_music(ctx, first) @commands.command(name="queue", help="Mostra as atuais músicas da fila.", aliases=['q', 'fila']) async def queue(self, ctx): From 0ab2a5a83031bc335dbf1f9e544e541ffb1ed214 Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Thu, 30 Dec 2021 20:38:48 -0400 Subject: [PATCH 3/3] Playlist will not more check if the returned music has source --- vulkanbot/music/Playlist.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vulkanbot/music/Playlist.py b/vulkanbot/music/Playlist.py index fb27da1..b290eb3 100644 --- a/vulkanbot/music/Playlist.py +++ b/vulkanbot/music/Playlist.py @@ -60,14 +60,11 @@ class Playlist(IPlaylist): return None self.__current = self.__queue[0] # Att the current with the first one - self.__queue.popleft() # Remove the current from queue - if self.__current.source == None: # Try until find one source - continue + self.__queue.popleft() # Remove the current from queue + self.__name_history.append(self.__current.identifier) # Add to name history + self.__songs_history.append(self.__current) # Add to song history - else: - self.__name_history.append(self.__current.title) # Add to name history - self.__songs_history.append(self.__current) # Add to song history - return self.__current + return self.__current def prev_song(self): """Return the source of the last song played