mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Upgrading tests in Downloader
This commit is contained in:
@@ -27,7 +27,7 @@ class Downloader():
|
||||
'default_search': 'auto',
|
||||
'playliststart': 0,
|
||||
'extract_flat': False,
|
||||
'playlistend': config.MAX_PLAYLIST_FORCED_LENGTH,
|
||||
'playlistend': config.MAX_PLAYLIST_LENGTH,
|
||||
'quiet': True
|
||||
}
|
||||
__BASE_URL = 'https://www.youtube.com/watch?v={}'
|
||||
@@ -53,7 +53,7 @@ class Downloader():
|
||||
|
||||
async def preload(self, songs: List[Song]) -> None:
|
||||
for song in songs:
|
||||
asyncio.ensure_future(self.__download_song(song))
|
||||
asyncio.ensure_future(self.download_song(song))
|
||||
|
||||
@run_async
|
||||
def extract_info(self, url: str) -> List[dict]:
|
||||
@@ -108,7 +108,7 @@ class Downloader():
|
||||
print(f'DEVELOPER NOTE -> Error Downloading URL {e}')
|
||||
return None
|
||||
|
||||
async def __download_song(self, song: Song) -> None:
|
||||
async def download_song(self, song: Song) -> None:
|
||||
if song.source is not None: # If Music already preloaded
|
||||
return None
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from Music.Downloader import Downloader
|
||||
from Music.Types import Provider
|
||||
from Music.Spotify import SpotifySearch
|
||||
from Utils.Utils import Utils
|
||||
from Utils.UrlAnalyzer import URLAnalyzer
|
||||
from Config.Messages import SearchMessages
|
||||
|
||||
|
||||
@@ -19,6 +20,7 @@ class Searcher():
|
||||
|
||||
elif provider == Provider.YouTube:
|
||||
try:
|
||||
track = self.__cleanYoutubeInput(track)
|
||||
musics = await self.__down.extract_info(track)
|
||||
return musics
|
||||
except:
|
||||
@@ -34,6 +36,16 @@ class Searcher():
|
||||
elif provider == Provider.Name:
|
||||
return [track]
|
||||
|
||||
def __cleanYoutubeInput(self, track: str) -> str:
|
||||
trackAnalyzer = URLAnalyzer(track)
|
||||
# Just ID and List arguments probably
|
||||
if trackAnalyzer.queryParamsQuant <= 2:
|
||||
return track
|
||||
|
||||
# Arguments used in Mix Youtube Playlists
|
||||
if 'start_radio' or 'index' in trackAnalyzer.queryParams.keys():
|
||||
return trackAnalyzer.getCleanedUrl()
|
||||
|
||||
def __identify_source(self, track) -> Provider:
|
||||
if not Utils.is_url(track):
|
||||
return Provider.Name
|
||||
|
||||
Reference in New Issue
Block a user