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): 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 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"""