aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-29 00:09:31 -0600
committerParker <contact@pkrm.dev>2024-11-29 00:09:31 -0600
commit8b231a1b54c51dd77106b02368f90b099305ab52 (patch)
tree82456a4cfb57f2e5eed535d6b044e9ecb7923775
parente73db927c17866793293868d915bf0e37a906737 (diff)
Only search YouTube when enabled
-rw-r--r--code/utils/custom_sources.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/code/utils/custom_sources.py b/code/utils/custom_sources.py
index 40544c1..50f0228 100644
--- a/code/utils/custom_sources.py
+++ b/code/utils/custom_sources.py
@@ -6,6 +6,8 @@ from lavalink import (
PlaylistInfo,
)
+from utils.config import YOUTUBE_SUPPORT
+
class LoadError(
Exception
@@ -32,21 +34,22 @@ class CustomAudioTrack(DeferredAudioTrack):
LoadType.EMPTY,
LoadType.ERROR,
):
- 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 YOUTUBE_SUPPORT:
+ 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,
):
- 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