From 2ca0e98312c629a164e26192c78bd983b756dba6 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sat, 25 Nov 2023 04:18:09 -0500 Subject: [PATCH] Don't show null values --- auto_editor/subcommands/info.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/auto_editor/subcommands/info.py b/auto_editor/subcommands/info.py index 479bd3ccc4..8f6b1ddd97 100644 --- a/auto_editor/subcommands/info.py +++ b/auto_editor/subcommands/info.py @@ -166,6 +166,9 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None: dump(file_info, sys.stdout, indent=4) return + def is_null(key: str, val: object) -> bool: + return val is None or (key in ("bitrate", "duration") and val == 0.0) + def stream_to_text(text: str, label: str, streams: list[dict[str, Any]]) -> str: if len(streams) > 0: text += f" - {label}:\n" @@ -173,11 +176,12 @@ def stream_to_text(text: str, label: str, streams: list[dict[str, Any]]) -> str: for s, stream in enumerate(streams): text += f" - track {s}:\n" for key, value in stream.items(): - if value is not None: + if not is_null(key, value): key = key.replace("_", " ") if isinstance(value, list): sep = "x" if key == "resolution" else ":" - value = sep.join([str(x) for x in value]) + + value = sep.join(f"{x}" for x in value) text += f" - {key}: {value}\n" return text