Use emojis for transcode status
This commit is contained in:
parent
d5466a2b09
commit
ec317d196a
1 changed files with 17 additions and 2 deletions
|
@ -50,6 +50,18 @@ class AutoResponder(commands.Cog):
|
|||
:param uri: The URI to transcode
|
||||
:return: A transcoded file
|
||||
"""
|
||||
last_reaction: str | None = None
|
||||
|
||||
def update_reaction(new: str | None = None) -> None:
|
||||
nonlocal last_reaction
|
||||
if not update:
|
||||
return
|
||||
if last_reaction is not None:
|
||||
_ = asyncio.create_task(update.remove_reaction(last_reaction, self.bot.user))
|
||||
if new:
|
||||
_ = asyncio.create_task(update.add_reaction(new))
|
||||
last_reaction = new
|
||||
|
||||
self.log.info("Waiting for transcode lock to release")
|
||||
async with self.transcode_lock:
|
||||
cog: FFMeta = self.bot.get_cog("FFMeta")
|
||||
|
@ -68,7 +80,7 @@ class AutoResponder(commands.Cog):
|
|||
uri,
|
||||
float(info["format"].get("duration", 600.1)),
|
||||
)
|
||||
return
|
||||
return update_reaction("\N{TIMER CLOCK}\U0000fe0f")
|
||||
streams = info.get("streams", [])
|
||||
for stream in streams:
|
||||
self.log.info("Found stream: %s", stream.get("codec_name"))
|
||||
|
@ -77,10 +89,11 @@ class AutoResponder(commands.Cog):
|
|||
break
|
||||
else:
|
||||
self.log.info("No HEVC streams found in %s", uri)
|
||||
return
|
||||
return update_reaction()
|
||||
extension = pathlib.Path(uri).suffix
|
||||
with tempfile.NamedTemporaryFile(suffix=extension) as tmp_dl:
|
||||
self.log.info("Downloading %r to %r", uri, tmp_dl.name)
|
||||
update_reaction("\N{INBOX TRAY}")
|
||||
async with aiohttp.ClientSession(
|
||||
headers={
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,"
|
||||
|
@ -105,6 +118,7 @@ class AutoResponder(commands.Cog):
|
|||
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmp:
|
||||
tmp_path = pathlib.Path(tmp.name)
|
||||
self.log.info("Transcoding %r to %r", uri, tmp_path)
|
||||
update_reaction("\N{HOURGLASS WITH FLOWING SAND}")
|
||||
args = [
|
||||
"-hide_banner",
|
||||
"-hwaccel",
|
||||
|
@ -148,6 +162,7 @@ class AutoResponder(commands.Cog):
|
|||
self.log.info("finished transcode with return code %d", process.returncode)
|
||||
self.log.debug("stdout: %r", stdout.decode)
|
||||
self.log.debug("stderr: %r", stderr.decode)
|
||||
update_reaction()
|
||||
if process.returncode != 0:
|
||||
raise subprocess.SubprocessError(
|
||||
process.returncode,
|
||||
|
|
Loading…
Reference in a new issue