mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-26 04:33:00 -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]):
|
if any([not query or not query.valid or query.is_spotify or query.is_local]):
|
||||||
return {}
|
return {}
|
||||||
await self._get_api_key()
|
await self._get_api_key()
|
||||||
|
if self.api_key is None:
|
||||||
|
return {}
|
||||||
search_response = "error"
|
search_response = "error"
|
||||||
query = query.lavalink_query
|
query = query.lavalink_query
|
||||||
with contextlib.suppress(aiohttp.ContentTypeError, asyncio.TimeoutError):
|
with contextlib.suppress(aiohttp.ContentTypeError, asyncio.TimeoutError):
|
||||||
@@ -91,6 +93,8 @@ class GlobalCacheWrapper:
|
|||||||
search_response = "error"
|
search_response = "error"
|
||||||
params = {"title": title, "author": author}
|
params = {"title": title, "author": author}
|
||||||
await self._get_api_key()
|
await self._get_api_key()
|
||||||
|
if self.api_key is None:
|
||||||
|
return {}
|
||||||
with contextlib.suppress(aiohttp.ContentTypeError, asyncio.TimeoutError):
|
with contextlib.suppress(aiohttp.ContentTypeError, asyncio.TimeoutError):
|
||||||
async with self.session.get(
|
async with self.session.get(
|
||||||
api_url,
|
api_url,
|
||||||
@@ -117,16 +121,13 @@ class GlobalCacheWrapper:
|
|||||||
return
|
return
|
||||||
query = Query.process_input(query, self.cog.local_folder_current_path)
|
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"]:
|
if llresponse.has_error or llresponse.load_type.value in ["NO_MATCHES", "LOAD_FAILED"]:
|
||||||
await asyncio.sleep(0)
|
|
||||||
return
|
return
|
||||||
if query and query.valid and query.is_youtube:
|
if query and query.valid and query.is_youtube:
|
||||||
query = query.lavalink_query
|
query = query.lavalink_query
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(0)
|
|
||||||
return None
|
return None
|
||||||
await self._get_api_key()
|
await self._get_api_key()
|
||||||
if self.api_key is None:
|
if self.api_key is None:
|
||||||
await asyncio.sleep(0)
|
|
||||||
return None
|
return None
|
||||||
api_url = f"{_API_URL}api/v2/queries"
|
api_url = f"{_API_URL}api/v2/queries"
|
||||||
async with self.session.post(
|
async with self.session.post(
|
||||||
@@ -164,6 +165,7 @@ class GlobalCacheWrapper:
|
|||||||
global_api_user = copy(self.cog.global_api_user)
|
global_api_user = copy(self.cog.global_api_user)
|
||||||
await self._get_api_key()
|
await self._get_api_key()
|
||||||
is_enabled = await self.config.global_db_enabled()
|
is_enabled = await self.config.global_db_enabled()
|
||||||
|
await self._get_api_key()
|
||||||
if (not is_enabled) or self.api_key is None:
|
if (not is_enabled) or self.api_key is None:
|
||||||
return global_api_user
|
return global_api_user
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
|
|||||||
@@ -516,32 +516,41 @@ class AudioAPIInterface:
|
|||||||
if isinstance(llresponse, LoadResult):
|
if isinstance(llresponse, LoadResult):
|
||||||
track_object = llresponse.tracks
|
track_object = llresponse.tracks
|
||||||
elif val:
|
elif val:
|
||||||
try:
|
result = None
|
||||||
(result, called_api) = await self.fetch_track(
|
if should_query_global:
|
||||||
ctx,
|
llresponse = await self.global_cache_api.get_call(val)
|
||||||
player,
|
if llresponse:
|
||||||
Query.process_input(val, self.cog.local_folder_current_path),
|
if llresponse.get("loadType") == "V2_COMPACT":
|
||||||
forced=forced,
|
llresponse["loadType"] = "V2_COMPAT"
|
||||||
should_query_global=not should_query_global,
|
llresponse = LoadResult(llresponse)
|
||||||
)
|
result = llresponse or None
|
||||||
except (RuntimeError, aiohttp.ServerDisconnectedError):
|
if not result:
|
||||||
lock(ctx, False)
|
try:
|
||||||
error_embed = discord.Embed(
|
(result, called_api) = await self.fetch_track(
|
||||||
colour=await ctx.embed_colour(),
|
ctx,
|
||||||
title=_("The connection was reset while loading the playlist."),
|
player,
|
||||||
)
|
Query.process_input(val, self.cog.local_folder_current_path),
|
||||||
if notifier is not None:
|
forced=forced,
|
||||||
await notifier.update_embed(error_embed)
|
should_query_global=not should_query_global,
|
||||||
break
|
)
|
||||||
except asyncio.TimeoutError:
|
except (RuntimeError, aiohttp.ServerDisconnectedError):
|
||||||
lock(ctx, False)
|
lock(ctx, False)
|
||||||
error_embed = discord.Embed(
|
error_embed = discord.Embed(
|
||||||
colour=await ctx.embed_colour(),
|
colour=await ctx.embed_colour(),
|
||||||
title=_("Player timeout, skipping remaining tracks."),
|
title=_("The connection was reset while loading the playlist."),
|
||||||
)
|
)
|
||||||
if notifier is not None:
|
if notifier is not None:
|
||||||
await notifier.update_embed(error_embed)
|
await notifier.update_embed(error_embed)
|
||||||
break
|
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
|
track_object = result.tracks
|
||||||
else:
|
else:
|
||||||
track_object = []
|
track_object = []
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
"""Hello, this message brings you an important update regarding the core Audio cog:
|
"""Hello, this message brings you an important update regarding the core Audio cog:
|
||||||
|
|
||||||
Starting from Audio v2.3.0+ you can take advantage of the **Global Audio API**, a new service offered by the Cog-Creators organization that allows your bot to greatly reduce the amount of requests done to YouTube / Spotify. This reduces the likelihood of YouTube rate-limiting your bot for making requests too often.
|
Starting from Audio v2.3.0+ you can take advantage of the **Global Audio API**, a new service offered by the Cog-Creators organization that allows your bot to greatly reduce the amount of requests done to YouTube / Spotify. This reduces the likelihood of YouTube rate-limiting your bot for making requests too often.
|
||||||
See `[p]help audioset globalapi` for more informations.
|
See `[p]help audioset globalapi` for more information.
|
||||||
Access to this service is disabled by default and **requires you to explicitly opt-in** to start using it.
|
Access to this service is disabled by default and **requires you to explicitly opt-in** to start using it.
|
||||||
|
|
||||||
An access token is **required** to use this API. To obtain this token you may join <https://discord.gg/red> and run `?audioapi register` in the #testing channel.
|
An access token is **required** to use this API. To obtain this token you may join <https://discord.gg/red> and run `?audioapi register` in the #testing channel.
|
||||||
|
|||||||
Reference in New Issue
Block a user