Only search YouTube when enabled
This commit is contained in:
parent
e73db927c1
commit
8b231a1b54
@ -6,6 +6,8 @@ from lavalink import (
|
|||||||
PlaylistInfo,
|
PlaylistInfo,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from utils.config import YOUTUBE_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
class LoadError(
|
class LoadError(
|
||||||
Exception
|
Exception
|
||||||
@ -32,21 +34,22 @@ class CustomAudioTrack(DeferredAudioTrack):
|
|||||||
LoadType.EMPTY,
|
LoadType.EMPTY,
|
||||||
LoadType.ERROR,
|
LoadType.ERROR,
|
||||||
):
|
):
|
||||||
ytmsearch = f"ytmsearch:{self.title} {self.author}"
|
if YOUTUBE_SUPPORT:
|
||||||
results = await client.get_tracks(ytmsearch)
|
ytmsearch = f"ytmsearch:{self.title} {self.author}"
|
||||||
|
results = await client.get_tracks(ytmsearch)
|
||||||
if not results.tracks or results.load_type in (
|
|
||||||
LoadType.EMPTY,
|
|
||||||
LoadType.ERROR,
|
|
||||||
):
|
|
||||||
ytsearch = f"ytsearch:{self.title} {self.author} audio"
|
|
||||||
results = await client.get_tracks(ytsearch)
|
|
||||||
|
|
||||||
if not results.tracks or results.load_type in (
|
if not results.tracks or results.load_type in (
|
||||||
LoadType.EMPTY,
|
LoadType.EMPTY,
|
||||||
LoadType.ERROR,
|
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[
|
first_track = results.tracks[
|
||||||
0
|
0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user