Merge pull request #5 from RafaelSolVargas/fixing-spotify-bug

Fixing Error #4
This commit is contained in:
Rafael Vargas 2021-12-30 22:32:58 -04:00 committed by GitHub
commit e82fc8c2f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 13 deletions

View File

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

View File

@ -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

View File

@ -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"""