Updating requirements and fixing small bug

This commit is contained in:
Rafael Vargas 2022-09-16 21:33:09 -03:00
parent ba57a3e18d
commit d10264b97c
5 changed files with 27 additions and 11 deletions

View File

@ -15,21 +15,24 @@ class Downloader:
'playliststart': 0, 'playliststart': 0,
'extract_flat': False, 'extract_flat': False,
'playlistend': config.MAX_PLAYLIST_LENGTH, 'playlistend': config.MAX_PLAYLIST_LENGTH,
'quiet': True 'quiet': True,
'ignore_no_formats_error': True
} }
__YDL_OPTIONS_EXTRACT = {'format': 'bestaudio/best', __YDL_OPTIONS_EXTRACT = {'format': 'bestaudio/best',
'default_search': 'auto', 'default_search': 'auto',
'playliststart': 0, 'playliststart': 0,
'extract_flat': True, 'extract_flat': True,
'playlistend': config.MAX_PLAYLIST_LENGTH, 'playlistend': config.MAX_PLAYLIST_LENGTH,
'quiet': True 'quiet': True,
'ignore_no_formats_error': True
} }
__YDL_OPTIONS_FORCE_EXTRACT = {'format': 'bestaudio/best', __YDL_OPTIONS_FORCE_EXTRACT = {'format': 'bestaudio/best',
'default_search': 'auto', 'default_search': 'auto',
'playliststart': 0, 'playliststart': 0,
'extract_flat': False, 'extract_flat': False,
'playlistend': config.MAX_PLAYLIST_LENGTH, 'playlistend': config.MAX_PLAYLIST_LENGTH,
'quiet': True 'quiet': True,
'ignore_no_formats_error': True
} }
__BASE_URL = 'https://www.youtube.com/watch?v={}' __BASE_URL = 'https://www.youtube.com/watch?v={}'
@ -110,7 +113,7 @@ class Downloader:
return result return result
except Exception as e: # Any type of error in download except Exception as e: # Any type of error in download
print(f'DEVELOPER NOTE -> Error Downloading URL {e}') print(f'DEVELOPER NOTE -> Error Downloading {url} -> {e}')
return None return None
async def download_song(self, song: Song) -> None: async def download_song(self, song: Song) -> None:
@ -118,12 +121,15 @@ class Downloader:
return None return None
def __download_func(song: Song) -> None: def __download_func(song: Song) -> None:
if Utils.is_url(song.identifier): try:
song_info = self.__download_url(song.identifier) if Utils.is_url(song.identifier):
else: song_info = self.__download_url(song.identifier)
song_info = self.__download_title(song.identifier) else:
song_info = self.__download_title(song.identifier)
song.finish_down(song_info) song.finish_down(song_info)
except Exception as e:
print(f'DEVELOPER NOTE -> Error Downloading {song.identifier} -> {e}')
# Creating a loop task to download each song # Creating a loop task to download each song
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()

View File

@ -28,6 +28,12 @@ class Song:
if key in info.keys(): if key in info.keys():
self.__info[key] = info[key] self.__info[key] = info[key]
self.__cleanTitle()
def __cleanTitle(self) -> None:
self.__info['title'] = ''.join(char if char.isalnum() or char ==
' ' else ' ' for char in self.__info['title'])
@property @property
def source(self) -> str: def source(self) -> str:
if 'url' in self.__info.keys(): if 'url' in self.__info.keys():

View File

@ -20,6 +20,7 @@ Vulkan uses multiprocessing and asynchronous Python modules to maximize Music Pl
- Manage the loop of one or all playing musics. - Manage the loop of one or all playing musics.
- Manage the order and remove musics from the queue. - Manage the order and remove musics from the queue.
- Shuffle the musics queue order. - Shuffle the musics queue order.
- Automatically clean the sended messages so it doesn't fill up your server.
<p align="center"> <p align="center">
@ -37,7 +38,9 @@ Vulkan uses multiprocessing and asynchronous Python modules to maximize Music Pl
### **Requirements** ### **Requirements**
Installation of Python 3.8+ and the dependencies in the requirements.txt file, creation of your own Bot in Discord and Spotify Keys. Installation of ``Python 3.10+`` and the dependencies in the requirements.txt file, creation of your own Bot in Discord and Spotify Keys. <br>
To install the dependencies type this command in the terminal, in the project root folder.
``` ```
pip install -r requirements.txt pip install -r requirements.txt
``` ```

View File

@ -21,7 +21,8 @@ class PlaylistDropdown(Select, AbstractItem):
values = [str(x) for x in range(1, len(songs) + 1)] values = [str(x) for x in range(1, len(songs) + 1)]
# Get the title of each of the 20 first songs, the pycord library doesn't accept more # Get the title of each of the 20 first songs, the pycord library doesn't accept more
songsNames: List[str] = [] songsNames: List[str] = []
for x in range(20): songsLength = min(20, len(songs))
for x in range(songsLength):
songsNames.append(f'{x + 1} - {songs[x].title[:80]}') songsNames.append(f'{x + 1} - {songs[x].title[:80]}')
selectOptions: List[SelectOption] = [] selectOptions: List[SelectOption] = []

Binary file not shown.