From a900f7742455413507f73c6540278b57feb7192b Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sat, 9 Oct 2021 17:30:16 -0400 Subject: [PATCH] Added better query parsing to get_tracks() to make it easier to search up keywords rather than having the end user implementing it themself --- pomice/pool.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pomice/pool.py b/pomice/pool.py index bca5b00..bd4de28 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -40,6 +40,9 @@ SPOTIFY_URL_REGEX = re.compile( DISCORD_MP3_URL_REGEX = re.compile( r"https?://cdn.discordapp.com/attachments/(?P[0-9]+)/(?P[0-9]+)/(?P[a-zA-Z0-9_.]+)+" ) +URL_REGEX = re.compile( + r'https?://(?:www\.)?.+' +) class Node: @@ -265,6 +268,10 @@ class Node: You can also pass in a discord.py Context object to get a Context object on any track you search. """ + + if not URL_REGEX.match(query): + query = f"{search_type}:{query}" + if spotify_url_check := SPOTIFY_URL_REGEX.match(query): if not self._spotify_client_id and not self._spotify_client_secret: raise InvalidSpotifyClientAuthorization(