aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/cogs/play.py24
-rw-r--r--code/utils/ai_recommendations.py24
-rw-r--r--code/utils/custom_sources.py24
3 files changed, 54 insertions, 18 deletions
diff --git a/code/cogs/play.py b/code/cogs/play.py
index 2e07486..76704ac 100644
--- a/code/cogs/play.py
+++ b/code/cogs/play.py
@@ -63,9 +63,15 @@ class Play(commands.Cog):
dzsearch = f"dzsearch:{query}"
results = await player.node.get_tracks(dzsearch)
# If Deezer returned nothing
- if not (results and results.tracks) or results.load_type in (
- LoadType.EMPTY,
- LoadType.ERROR,
+ if (
+ not results
+ or not results.tracks
+ or not results.load_type
+ or results.load_type
+ in (
+ LoadType.EMPTY,
+ LoadType.ERROR,
+ )
):
if YOUTUBE_SUPPORT:
ytmsearch = f"ytmsearch:{query}"
@@ -84,9 +90,15 @@ class Play(commands.Cog):
results = await player.node.get_tracks(query)
# If there are no results found, set results/embed to None, handled further down
- if not (results and results.tracks) or results.load_type in (
- LoadType.EMPTY,
- LoadType.ERROR,
+ if (
+ not results
+ or not results.tracks
+ or not results.load_type
+ or results.load_type
+ in (
+ LoadType.EMPTY,
+ LoadType.ERROR,
+ )
):
results, embed = None, None
diff --git a/code/utils/ai_recommendations.py b/code/utils/ai_recommendations.py
index 2fc71d3..1ff5415 100644
--- a/code/utils/ai_recommendations.py
+++ b/code/utils/ai_recommendations.py
@@ -62,16 +62,28 @@ async def add_song_recommendations(
ytsearch = f"ytsearch:{song} by {artist} audio"
results = await player.node.get_tracks(ytsearch)
- if not (results and results.tracks) or results.load_type in (
- LoadType.EMPTY,
- LoadType.ERROR,
+ if (
+ not results
+ or not results.tracks
+ or not results.load_type
+ or results.load_type
+ in (
+ LoadType.EMPTY,
+ LoadType.ERROR,
+ )
):
dzsearch = f"dzsearch:{song}"
results = await player.node.get_tracks(dzsearch)
- if not (results and results.tracks) or results.load_type in (
- LoadType.EMPTY,
- LoadType.ERROR,
+ if (
+ not results
+ or not results.tracks
+ or not results.load_type
+ or results.load_type
+ in (
+ LoadType.EMPTY,
+ LoadType.ERROR,
+ )
):
continue
diff --git a/code/utils/custom_sources.py b/code/utils/custom_sources.py
index 063b886..8895b7c 100644
--- a/code/utils/custom_sources.py
+++ b/code/utils/custom_sources.py
@@ -30,17 +30,29 @@ class CustomAudioTrack(DeferredAudioTrack):
): # Load our 'actual' playback track using the metadata from this one.
dzsearch = f"dzsearch:{self.title} {self.author}"
results = await client.get_tracks(dzsearch)
- if not (results and results.tracks) or results.load_type in (
- LoadType.EMPTY,
- LoadType.ERROR,
+ if (
+ not results
+ or not results.tracks
+ or not results.load_type
+ or results.load_type
+ in (
+ LoadType.EMPTY,
+ LoadType.ERROR,
+ )
):
if YOUTUBE_SUPPORT:
ytmsearch = f"ytmsearch:{self.title} {self.author}"
results = await client.get_tracks(ytmsearch)
- if not (results and results.tracks) or results.load_type in (
- LoadType.EMPTY,
- LoadType.ERROR,
+ if (
+ not results
+ or not results.tracks
+ or not results.load_type
+ or results.load_type
+ in (
+ LoadType.EMPTY,
+ LoadType.ERROR,
+ )
):
ytsearch = f"ytsearch:{self.title} {self.author} audio"
results = await client.get_tracks(ytsearch)