refactor: update search_type handling in Player and Node classes to be nullish to support lavasrc
This commit is contained in:
parent
8679d6d125
commit
80f7b77cd3
|
|
@ -396,7 +396,7 @@ class Player(VoiceProtocol):
|
||||||
query: str,
|
query: str,
|
||||||
*,
|
*,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
search_type: SearchType = SearchType.ytsearch,
|
search_type: SearchType | None = SearchType.ytsearch,
|
||||||
filters: Optional[List[Filter]] = None,
|
filters: Optional[List[Filter]] = None,
|
||||||
) -> Optional[Union[List[Track], Playlist]]:
|
) -> Optional[Union[List[Track], Playlist]]:
|
||||||
"""Fetches tracks from the node's REST api to parse into Lavalink.
|
"""Fetches tracks from the node's REST api to parse into Lavalink.
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ class Node:
|
||||||
query: str,
|
query: str,
|
||||||
*,
|
*,
|
||||||
ctx: Optional[commands.Context] = None,
|
ctx: Optional[commands.Context] = None,
|
||||||
search_type: SearchType = SearchType.ytsearch,
|
search_type: SearchType | None = SearchType.ytsearch,
|
||||||
filters: Optional[List[Filter]] = None,
|
filters: Optional[List[Filter]] = None,
|
||||||
) -> Optional[Union[Playlist, List[Track]]]:
|
) -> Optional[Union[Playlist, List[Track]]]:
|
||||||
"""Fetches tracks from the node's REST api to parse into Lavalink.
|
"""Fetches tracks from the node's REST api to parse into Lavalink.
|
||||||
|
|
@ -707,7 +707,11 @@ class Node:
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not URLRegex.BASE_URL.match(query) and not re.match(r"(?:[a-z]+?)search:.", query):
|
if (
|
||||||
|
search_type
|
||||||
|
and not URLRegex.BASE_URL.match(query)
|
||||||
|
and not re.match(r"(?:[a-z]+?)search:.", query)
|
||||||
|
):
|
||||||
query = f"{search_type}:{query}"
|
query = f"{search_type}:{query}"
|
||||||
|
|
||||||
# If YouTube url contains a timestamp, capture it for use later.
|
# If YouTube url contains a timestamp, capture it for use later.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue