From f209a8fb0048be7e58e37ee13d4bdd4477885f67 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sat, 16 Mar 2024 01:11:12 -0400 Subject: [PATCH] Improve subdump --- auto_editor/subcommands/subdump.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/auto_editor/subcommands/subdump.py b/auto_editor/subcommands/subdump.py index 04c3072c1..a7ed7095c 100644 --- a/auto_editor/subcommands/subdump.py +++ b/auto_editor/subcommands/subdump.py @@ -1,26 +1,23 @@ import sys -from dataclasses import dataclass, field - -from auto_editor.utils.log import Log import av +from av.subtitles.subtitle import SubtitleSet def main(sys_args: list[str] = sys.argv[1:]) -> None: for i, input_file in enumerate(sys_args): with av.open(input_file) as container: for s in range(len(container.streams.subtitles)): - print(f"file: {input_file} ({s})") + print(f"file: {input_file} ({s}:{container.streams.subtitles[s].name})") for packet in container.demux(subtitles=s): for item in packet.decode(): - if type(item) is av.subtitles.subtitle.SubtitleSet and item: + if type(item) is SubtitleSet and item: if item[0].type == b"ass": print(item[0].ass.decode("utf-8")) - else: + elif item[0].type == b"text": print(item[0].text) print("------") - if __name__ == "__main__": main()