mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-26 12:43:01 -05:00
update
This commit is contained in:
@@ -61,6 +61,8 @@ class GlobalCacheWrapper:
|
||||
if any([not query or not query.valid or query.is_spotify or query.is_local]):
|
||||
return {}
|
||||
await self._get_api_key()
|
||||
if self.api_key is None:
|
||||
return {}
|
||||
search_response = "error"
|
||||
query = query.lavalink_query
|
||||
with contextlib.suppress(aiohttp.ContentTypeError, asyncio.TimeoutError):
|
||||
@@ -91,6 +93,8 @@ class GlobalCacheWrapper:
|
||||
search_response = "error"
|
||||
params = {"title": title, "author": author}
|
||||
await self._get_api_key()
|
||||
if self.api_key is None:
|
||||
return {}
|
||||
with contextlib.suppress(aiohttp.ContentTypeError, asyncio.TimeoutError):
|
||||
async with self.session.get(
|
||||
api_url,
|
||||
@@ -117,16 +121,13 @@ class GlobalCacheWrapper:
|
||||
return
|
||||
query = Query.process_input(query, self.cog.local_folder_current_path)
|
||||
if llresponse.has_error or llresponse.load_type.value in ["NO_MATCHES", "LOAD_FAILED"]:
|
||||
await asyncio.sleep(0)
|
||||
return
|
||||
if query and query.valid and query.is_youtube:
|
||||
query = query.lavalink_query
|
||||
else:
|
||||
await asyncio.sleep(0)
|
||||
return None
|
||||
await self._get_api_key()
|
||||
if self.api_key is None:
|
||||
await asyncio.sleep(0)
|
||||
return None
|
||||
api_url = f"{_API_URL}api/v2/queries"
|
||||
async with self.session.post(
|
||||
@@ -164,6 +165,7 @@ class GlobalCacheWrapper:
|
||||
global_api_user = copy(self.cog.global_api_user)
|
||||
await self._get_api_key()
|
||||
is_enabled = await self.config.global_db_enabled()
|
||||
await self._get_api_key()
|
||||
if (not is_enabled) or self.api_key is None:
|
||||
return global_api_user
|
||||
with contextlib.suppress(Exception):
|
||||
|
||||
@@ -516,32 +516,41 @@ class AudioAPIInterface:
|
||||
if isinstance(llresponse, LoadResult):
|
||||
track_object = llresponse.tracks
|
||||
elif val:
|
||||
try:
|
||||
(result, called_api) = await self.fetch_track(
|
||||
ctx,
|
||||
player,
|
||||
Query.process_input(val, self.cog.local_folder_current_path),
|
||||
forced=forced,
|
||||
should_query_global=not should_query_global,
|
||||
)
|
||||
except (RuntimeError, aiohttp.ServerDisconnectedError):
|
||||
lock(ctx, False)
|
||||
error_embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("The connection was reset while loading the playlist."),
|
||||
)
|
||||
if notifier is not None:
|
||||
await notifier.update_embed(error_embed)
|
||||
break
|
||||
except asyncio.TimeoutError:
|
||||
lock(ctx, False)
|
||||
error_embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("Player timeout, skipping remaining tracks."),
|
||||
)
|
||||
if notifier is not None:
|
||||
await notifier.update_embed(error_embed)
|
||||
break
|
||||
result = None
|
||||
if should_query_global:
|
||||
llresponse = await self.global_cache_api.get_call(val)
|
||||
if llresponse:
|
||||
if llresponse.get("loadType") == "V2_COMPACT":
|
||||
llresponse["loadType"] = "V2_COMPAT"
|
||||
llresponse = LoadResult(llresponse)
|
||||
result = llresponse or None
|
||||
if not result:
|
||||
try:
|
||||
(result, called_api) = await self.fetch_track(
|
||||
ctx,
|
||||
player,
|
||||
Query.process_input(val, self.cog.local_folder_current_path),
|
||||
forced=forced,
|
||||
should_query_global=not should_query_global,
|
||||
)
|
||||
except (RuntimeError, aiohttp.ServerDisconnectedError):
|
||||
lock(ctx, False)
|
||||
error_embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("The connection was reset while loading the playlist."),
|
||||
)
|
||||
if notifier is not None:
|
||||
await notifier.update_embed(error_embed)
|
||||
break
|
||||
except asyncio.TimeoutError:
|
||||
lock(ctx, False)
|
||||
error_embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("Player timeout, skipping remaining tracks."),
|
||||
)
|
||||
if notifier is not None:
|
||||
await notifier.update_embed(error_embed)
|
||||
break
|
||||
track_object = result.tracks
|
||||
else:
|
||||
track_object = []
|
||||
|
||||
Reference in New Issue
Block a user