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
|
:param uri: The URI to transcode
|
||||||
:return: A transcoded file
|
: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")
|
self.log.info("Waiting for transcode lock to release")
|
||||||
async with self.transcode_lock:
|
async with self.transcode_lock:
|
||||||
cog: FFMeta = self.bot.get_cog("FFMeta")
|
cog: FFMeta = self.bot.get_cog("FFMeta")
|
||||||
|
@ -68,7 +80,7 @@ class AutoResponder(commands.Cog):
|
||||||
uri,
|
uri,
|
||||||
float(info["format"].get("duration", 600.1)),
|
float(info["format"].get("duration", 600.1)),
|
||||||
)
|
)
|
||||||
return
|
return update_reaction("\N{TIMER CLOCK}\U0000fe0f")
|
||||||
streams = info.get("streams", [])
|
streams = info.get("streams", [])
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
self.log.info("Found stream: %s", stream.get("codec_name"))
|
self.log.info("Found stream: %s", stream.get("codec_name"))
|
||||||
|
@ -77,10 +89,11 @@ class AutoResponder(commands.Cog):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.log.info("No HEVC streams found in %s", uri)
|
self.log.info("No HEVC streams found in %s", uri)
|
||||||
return
|
return update_reaction()
|
||||||
extension = pathlib.Path(uri).suffix
|
extension = pathlib.Path(uri).suffix
|
||||||
with tempfile.NamedTemporaryFile(suffix=extension) as tmp_dl:
|
with tempfile.NamedTemporaryFile(suffix=extension) as tmp_dl:
|
||||||
self.log.info("Downloading %r to %r", uri, tmp_dl.name)
|
self.log.info("Downloading %r to %r", uri, tmp_dl.name)
|
||||||
|
update_reaction("\N{INBOX TRAY}")
|
||||||
async with aiohttp.ClientSession(
|
async with aiohttp.ClientSession(
|
||||||
headers={
|
headers={
|
||||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,"
|
"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:
|
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmp:
|
||||||
tmp_path = pathlib.Path(tmp.name)
|
tmp_path = pathlib.Path(tmp.name)
|
||||||
self.log.info("Transcoding %r to %r", uri, tmp_path)
|
self.log.info("Transcoding %r to %r", uri, tmp_path)
|
||||||
|
update_reaction("\N{HOURGLASS WITH FLOWING SAND}")
|
||||||
args = [
|
args = [
|
||||||
"-hide_banner",
|
"-hide_banner",
|
||||||
"-hwaccel",
|
"-hwaccel",
|
||||||
|
@ -148,6 +162,7 @@ class AutoResponder(commands.Cog):
|
||||||
self.log.info("finished transcode with return code %d", process.returncode)
|
self.log.info("finished transcode with return code %d", process.returncode)
|
||||||
self.log.debug("stdout: %r", stdout.decode)
|
self.log.debug("stdout: %r", stdout.decode)
|
||||||
self.log.debug("stderr: %r", stderr.decode)
|
self.log.debug("stderr: %r", stderr.decode)
|
||||||
|
update_reaction()
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
raise subprocess.SubprocessError(
|
raise subprocess.SubprocessError(
|
||||||
process.returncode,
|
process.returncode,
|
||||||
|
|
Loading…
Reference in a new issue