diff --git a/HEROKU.md b/HEROKU.md index fbcd3b2..412e726 100644 --- a/HEROKU.md +++ b/HEROKU.md @@ -1,6 +1,8 @@

Configuring Heroku

-Nobody wants to run the Vulkan process on their machine, so we host the process on Heroku, a cloud platform that contains free accounts.
+> Heroku doesn't offer free services anymore + +Nobody wants to run the Vulkan process on their machine, so we host the process on Heroku, a cloud platform that contains free.
To configure the Vulkan to run in your Heroku account you will need to: - Create an application project in Heroku. diff --git a/Handlers/PlayHandler.py b/Handlers/PlayHandler.py index 7003689..218db30 100644 --- a/Handlers/PlayHandler.py +++ b/Handlers/PlayHandler.py @@ -82,6 +82,12 @@ class PlayHandler(AbstractHandler): return response else: # If multiple songs added + # If more than 10 songs, download and load the first 5 to start the play right away + if len(songs) > 10: + fiveFirstSongs = songs[0:5] + songs = songs[5:] + await self.__downloadSongsAndStore(fiveFirstSongs, processInfo) + # Trigger a task to download all songs and then store them in the process playlist asyncio.create_task(self.__downloadSongsAndStore(songs, processInfo)) @@ -92,13 +98,10 @@ class PlayHandler(AbstractHandler): embed = self.embeds.DOWNLOADING_ERROR() return HandlerResponse(self.ctx, embed, error) except Exception as error: + print(f'ERROR IN PLAYHANDLER -> {traceback.format_exc()}', {type(error)}) if isinstance(error, VulkanError): # If error was already processed - print( - f'DEVELOPER NOTE -s> PlayController Error: {traceback.format_exc()}', {type(error)}) embed = self.embeds.CUSTOM_ERROR(error) else: - print( - f'DEVELOPER NOTE -> PlayController Error: {traceback.format_exc()}, {type(error)}') error = UnknownError() embed = self.embeds.UNKNOWN_ERROR() @@ -108,13 +111,19 @@ class PlayHandler(AbstractHandler): playlist = processInfo.getPlaylist() queue = processInfo.getQueueToPlayer() playCommand = VCommands(VCommandsType.PLAY, None) + tooManySongs = len(songs) > 100 + # Trigger a task for each song to be downloaded tasks: List[asyncio.Task] = [] - for song in songs: + for index, song in enumerate(songs): + # If there is a lot of songs being downloaded, force a sleep to try resolve the Http Error 429 "To Many Requests" + # Trying to fix the issue https://github.com/RafaelSolVargas/Vulkan/issues/32 + if tooManySongs and index % 3 == 0: + await asyncio.sleep(0.5) task = asyncio.create_task(self.__down.download_song(song)) tasks.append(task) - # In the original order, await for the task and then if successfully downloaded add in the playlist + # In the original order, await for the task and then, if successfully downloaded, add to the playlist processManager = self.config.getProcessManager() for index, task in enumerate(tasks): await task diff --git a/Music/Downloader.py b/Music/Downloader.py index ecdebf5..b3b3dd2 100644 --- a/Music/Downloader.py +++ b/Music/Downloader.py @@ -151,6 +151,8 @@ class Downloader: return {} if self.__is_multiple_musics(extracted_info): + if len(extracted_info['entries']) == 0: + return {} return extracted_info['entries'][0] else: print(f'DEVELOPER NOTE -> Failed to extract title {title}') diff --git a/Music/Song.py b/Music/Song.py index 0fa9971..a1bf00b 100644 --- a/Music/Song.py +++ b/Music/Song.py @@ -6,7 +6,7 @@ class Song: self.__playlist = playlist def finish_down(self, info: dict) -> None: - if info is None: + if info is None or info == {}: self.destroy() return None @@ -20,7 +20,8 @@ class Song: if key in info.keys(): self.__info[key] = info[key] else: - print(f'DEVELOPER NOTE -> {key} not found in info of music: {self.identifier}') + print( + f'DEVELOPER NOTE -> Required information [{key}] was not found in the music: {self.identifier}') self.destroy() return @@ -64,7 +65,7 @@ class Song: return self.__problematic def destroy(self) -> None: - print(f'DEVELOPER NOTE -> Music self destroying {self.__identifier}') + print(f'MUSIC ERROR -> Music self destroying {self.__identifier}') self.__problematic = True self.__playlist.destroy_song(self) diff --git a/README.md b/README.md index 4fbf3cf..fc42c47 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,9 @@ The config file is located at ```./config/Configs.py```, it doesn't require any

-## **๐Ÿš€ Heroku** +## **๐Ÿš€ Heroku (Not free anymore)** +> *Heroku doesn't offer free host services anymore.*
+ To deploy and run your Bot in Heroku 24/7, follow the instructions in the [Heroku Instructions](HEROKU.md) page. ## ๐Ÿงช Tests diff --git a/requirements.txt b/requirements.txt index 2d88d47..476b8f1 100644 Binary files a/requirements.txt and b/requirements.txt differ