From c336b37a9cdad77a91eeb54ddd88a903d1522306 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Thu, 25 Dec 2025 00:32:51 -0500 Subject: [PATCH] in reenc too --- queuers/reenc.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/queuers/reenc.py b/queuers/reenc.py index 646620c5688aa4ec5e2f80240def832d33ac6b62..052063373285c9bd5a5687ab6266c0f9b783c1a1 100644 --- a/queuers/reenc.py +++ b/queuers/reenc.py @@ -36,6 +36,22 @@ def usage(): print(f'usage: {argv0} ', file=stderr) exit(-1) +class JobError(Exception): + pass +def send_cmd(reader, writer, cmd): + lines = [] + + writer.write(cmd.encode()+b'\n') + writer.flush() + while True: + line = reader.readline() + if line == '?\n': + raise JobError(cmd) + elif line == 'OKAY\n': + return lines + else: + lines.append(line.strip()) + @dataclass class Episode: @@ -65,7 +81,7 @@ class Episode: inparg = shlex.quote(str(self.file)) outarg = shlex.quote(str(outpath)) dirarg = shlex.quote(str(outpath.parent)) - return '#!/bin/sh\n' f'mkdir -p {dirarg}\n' f'ffmpeg -loglevel quiet -i {inparg} -map 0 -c:a copy -c:s ass -c:v h264 -s {wid}x{hei} {outarg}\n' + return '#!/bin/sh\n' f'mkdir -p {dirarg}\n' f'ffmpeg -loglevel error -i {inparg} -map 0 -c:a copy -c:s ass -c:v h264 -s {wid}x{hei} {outarg}\n' def slug(self): if self.season == 0: @@ -210,14 +226,9 @@ def queue_job(reader, writer, show, res, episode): jid = int(jid) reader.readline() - writer.write(f'META name IS {jobname}\n'.encode()) - writer.flush() - reader.readline() + send_cmd(reader, writer, f'META name IS {jobname}') + send_cmd(reader, writer, 'MARK AS available') - writer.write(f'MARK AS available\n'.encode()) - writer.flush() - reader.readline() - print(f'{jobname} queued as {jid}')