mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 18:06:08 -05:00
I promise I'm not doing this on purpose (#4565)
* Prep for 0.7.2 * So What di i do here? I done Magic, magic only found in the tales of old. * turns out formatting is something important * fixes * improved Error handling when Global API is enabled * further improve resuming logic * more of dat dark voodoo blood magic * major tweaks to auto restore when auto play is enabled 👀 * fix duplicated "Auto play stated." message + Auto play restart :feelsgoodman: * missed these * fix the new duplicated fucking message bitch. * Let discord handle player reconnects * eh * `Requires force install`, utilize new Exponential Backoff object on player and safer reconnect logic, emulating d.py and WL. * hmmmmm gotta monitor * mother fucking brackets * Why didnt i consider this the first time????????????? * new error code to handle? * soooooooooooooooo these are import so why arent we ensuring they are set. * improved logging * improved logging * aaaaaaaaaaaaaaa * We need our own error and special handling to not conflict with dpy * (Last Known Bug) Fix the infinite loop of 4006 that sometimes could happen as an edge case after a successful resume. * This will require a force reinstall to install `RLL 0.8.0`, this properly fixes the bug mentioned on the previous commit. * address "Localtrack names/paths need to be escaped." comment * address Fixators crash mentioned in #AT * style * fix preda's crash mentioned in PR * add a thing here add a thing there add a thing everywhere * style * fixes here, fixes there, and backbone for curated playlist. * bypass aiohttp and githubs and cloudflare and yo mammas cache * I propose the new style is no style. * allow curated playlist to be updated it `[p]playlist update` and show the diff * fix `[p]summon` not resuming playback until next track. * Hopefully handle predas rate limits. * what else did i break now * Update Lavalink.jar build * lets try this * reset the queue * Bring Edge commits over fix a bunch of shiz again * Bring Edge commits over fix a bunch of shiz again * Handle 4014 OPs, Change `skip_votes` key to be an int rather than guild object * aaaaaaaaaaaaaaa im dumb * ... * Simplify some shiz + use a set instead of a list for votes. Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
This commit is contained in:
@@ -211,6 +211,7 @@ class AudioAPIInterface:
|
||||
time_now = int(datetime.datetime.now(datetime.timezone.utc).timestamp())
|
||||
youtube_cache = CacheLevel.set_youtube().is_subset(current_cache_level)
|
||||
youtube_api_error = None
|
||||
global_api = self.cog.global_api_user.get("can_read")
|
||||
async for track in AsyncIter(tracks):
|
||||
if isinstance(track, str):
|
||||
break
|
||||
@@ -267,13 +268,15 @@ class AudioAPIInterface:
|
||||
track_count += 1
|
||||
if notifier is not None and ((track_count % 2 == 0) or (track_count == total_tracks)):
|
||||
await notifier.notify_user(current=track_count, total=total_tracks, key="youtube")
|
||||
if notifier is not None and youtube_api_error:
|
||||
if notifier is not None and (youtube_api_error and not global_api):
|
||||
error_embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("Failing to get tracks, skipping remaining."),
|
||||
)
|
||||
await notifier.update_embed(error_embed)
|
||||
break
|
||||
elif notifier is not None and (youtube_api_error and global_api):
|
||||
continue
|
||||
if CacheLevel.set_spotify().is_subset(current_cache_level):
|
||||
task = ("insert", ("spotify", database_entries))
|
||||
self.append_task(ctx, *task)
|
||||
@@ -447,11 +450,12 @@ class AudioAPIInterface:
|
||||
List of Youtube URLs.
|
||||
"""
|
||||
await self.global_cache_api._get_api_key()
|
||||
globaldb_toggle = await self.config.global_db_enabled()
|
||||
globaldb_toggle = self.cog.global_api_user.get("can_read")
|
||||
global_entry = globaldb_toggle and query_global
|
||||
track_list: List = []
|
||||
has_not_allowed = False
|
||||
youtube_api_error = None
|
||||
skip_youtube_api = False
|
||||
try:
|
||||
current_cache_level = CacheLevel(await self.config.cache_level())
|
||||
guild_data = await self.config.guild(ctx.guild).all()
|
||||
@@ -518,7 +522,7 @@ class AudioAPIInterface:
|
||||
llresponse["loadType"] = "V2_COMPAT"
|
||||
llresponse = LoadResult(llresponse)
|
||||
val = llresponse or None
|
||||
if val is None:
|
||||
if val is None and not skip_youtube_api:
|
||||
try:
|
||||
val = await self.fetch_youtube_query(
|
||||
ctx, track_info, current_cache_level=current_cache_level
|
||||
@@ -526,6 +530,7 @@ class AudioAPIInterface:
|
||||
except YouTubeApiError as err:
|
||||
val = None
|
||||
youtube_api_error = err.message
|
||||
skip_youtube_api = True
|
||||
if not youtube_api_error:
|
||||
if youtube_cache and val and llresponse is None:
|
||||
task = ("update", ("youtube", {"track": track_info}))
|
||||
@@ -589,7 +594,9 @@ class AudioAPIInterface:
|
||||
seconds=seconds,
|
||||
)
|
||||
|
||||
if youtube_api_error or consecutive_fails >= (20 if global_entry else 10):
|
||||
if (youtube_api_error and not global_entry) or consecutive_fails >= (
|
||||
20 if global_entry else 10
|
||||
):
|
||||
error_embed = discord.Embed(
|
||||
colour=await ctx.embed_colour(),
|
||||
title=_("Failing to get tracks, skipping remaining."),
|
||||
@@ -793,7 +800,7 @@ class AudioAPIInterface:
|
||||
val = None
|
||||
query = Query.process_input(query, self.cog.local_folder_current_path)
|
||||
query_string = str(query)
|
||||
globaldb_toggle = await self.config.global_db_enabled()
|
||||
globaldb_toggle = self.cog.global_api_user.get("can_read")
|
||||
valid_global_entry = False
|
||||
results = None
|
||||
called_api = False
|
||||
@@ -925,6 +932,7 @@ class AudioAPIInterface:
|
||||
autoplaylist = await self.config.guild(player.channel.guild).autoplaylist()
|
||||
current_cache_level = CacheLevel(await self.config.cache_level())
|
||||
cache_enabled = CacheLevel.set_lavalink().is_subset(current_cache_level)
|
||||
notify_channel_id = player.fetch("channel")
|
||||
playlist = None
|
||||
tracks = None
|
||||
if autoplaylist["enabled"]:
|
||||
@@ -973,7 +981,7 @@ class AudioAPIInterface:
|
||||
and not query.local_track_path.exists()
|
||||
):
|
||||
continue
|
||||
notify_channel = self.bot.get_channel(player.fetch("channel"))
|
||||
notify_channel = self.bot.get_channel(notify_channel_id)
|
||||
if not await self.cog.is_query_allowed(
|
||||
self.config,
|
||||
notify_channel,
|
||||
@@ -997,8 +1005,20 @@ class AudioAPIInterface:
|
||||
)
|
||||
player.add(player.channel.guild.me, track)
|
||||
self.bot.dispatch(
|
||||
"red_audio_track_auto_play", player.channel.guild, track, player.channel.guild.me
|
||||
"red_audio_track_auto_play",
|
||||
player.channel.guild,
|
||||
track,
|
||||
player.channel.guild.me,
|
||||
player,
|
||||
)
|
||||
if notify_channel_id:
|
||||
await self.config.guild_from_id(
|
||||
guild_id=player.channel.guild.id
|
||||
).currently_auto_playing_in.set([notify_channel_id, player.channel.id])
|
||||
else:
|
||||
await self.config.guild_from_id(
|
||||
guild_id=player.channel.guild.id
|
||||
).currently_auto_playing_in.set([])
|
||||
if not player.current:
|
||||
await player.play()
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ class PlaylistCompat23:
|
||||
Trying to access the User scope without an user id.
|
||||
"""
|
||||
guild = data.get("guild") or kwargs.get("guild")
|
||||
author: int = data.get("author") or 0
|
||||
author: int = data.get("author") or kwargs.get("author") or 0
|
||||
playlist_id = data.get("id") or playlist_number
|
||||
name = data.get("name", "Unnamed")
|
||||
playlist_url = data.get("playlist_url", None)
|
||||
|
||||
Reference in New Issue
Block a user