Switch up search providers

This commit is contained in:
Parker M. 2024-07-24 20:28:04 -05:00
parent 8e84d9e11f
commit 2f088fab5d
No known key found for this signature in database
GPG Key ID: 95CD2E0C7E329F2A
2 changed files with 23 additions and 9 deletions

View File

@ -233,15 +233,22 @@ class Play(commands.Cog):
else:
if not url_rx.match(query):
ytsearch = f"ytsearch:{query}"
results = await player.node.get_tracks(ytsearch)
dzsearch = f"dzsearch:{query}"
results = await player.node.get_tracks(dzsearch)
if not results.tracks or results.load_type in (
LoadType.EMPTY,
LoadType.ERROR,
):
dzsearch = f"dzsearch:{query}"
results = await player.node.get_tracks(dzsearch)
scsearch = f"scsearch:{query}"
results = await player.node.get_tracks(scsearch)
if not results.tracks or results.load_type in (
LoadType.EMPTY,
LoadType.ERROR,
):
ytsearch = f"ytsearch:{query}"
results = await player.node.get_tracks(ytsearch)
else:
results = await player.node.get_tracks(query)

View File

@ -18,20 +18,27 @@ class CustomAudioTrack(DeferredAudioTrack):
async def load(
self, client
): # Load our 'actual' playback track using the metadata from this one.
ytsearch = f"ytsearch:{self.title} {self.author} audio"
results = await client.get_tracks(ytsearch)
dzsearch = f"dzsearch:{self.title} {self.author}"
results = await client.get_tracks(dzsearch)
if not results.tracks or results.load_type in (
LoadType.EMPTY,
LoadType.ERROR,
):
dzsearch = f"dzsearch:{self.title} {self.author}"
results = await client.get_tracks(dzsearch)
scsearch = f"scsearch:{self.title} {self.author}"
results = await client.get_tracks(scsearch)
if not results.tracks or results.load_type in (
LoadType.EMPTY,
LoadType.ERROR,
):
raise LoadError
ytsearch = f"ytsearch:{self.title} {self.author} audio"
results = await client.get_tracks(ytsearch)
if not results.tracks or results.load_type in (
LoadType.EMPTY,
LoadType.ERROR,
):
raise LoadError
first_track = results.tracks[0] # Grab the first track from the results.
base64 = first_track.track # Extract the base64 string from the track.