Have a 30 second cooldown between transcodes
This commit is contained in:
parent
7a43c204d3
commit
5e1b0bb22e
1 changed files with 8 additions and 0 deletions
|
@ -88,6 +88,13 @@ class AutoResponder(commands.Cog):
|
||||||
links.append(url.geturl() if raw is False else url)
|
links.append(url.geturl() if raw is False else url)
|
||||||
return links
|
return links
|
||||||
|
|
||||||
|
def _cooldown_transcode(self, timeout: float = 30.0):
|
||||||
|
async def _i():
|
||||||
|
async with self.transcode_lock:
|
||||||
|
await asyncio.sleep(timeout)
|
||||||
|
|
||||||
|
self.bot.loop.create_task(_i())
|
||||||
|
|
||||||
async def _transcode_hevc_to_h264(
|
async def _transcode_hevc_to_h264(
|
||||||
self, uri: str | pathlib.Path, *, update: discord.Message = None
|
self, uri: str | pathlib.Path, *, update: discord.Message = None
|
||||||
) -> tuple[discord.File, pathlib.Path] | None:
|
) -> tuple[discord.File, pathlib.Path] | None:
|
||||||
|
@ -261,6 +268,7 @@ class AutoResponder(commands.Cog):
|
||||||
_r = await self._transcode_hevc_to_h264(link, update=message)
|
_r = await self._transcode_hevc_to_h264(link, update=message)
|
||||||
if not _r:
|
if not _r:
|
||||||
continue
|
continue
|
||||||
|
self._cooldown_transcode()
|
||||||
file, _p = _r
|
file, _p = _r
|
||||||
if file:
|
if file:
|
||||||
if _p.stat().st_size <= 24.5 * 1024 * 1024:
|
if _p.stat().st_size <= 24.5 * 1024 * 1024:
|
||||||
|
|
Loading…
Reference in a new issue