Skip to content

Commit

Permalink
Don't show null values
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Nov 25, 2023
1 parent 12461cb commit 2ca0e98
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions auto_editor/subcommands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,22 @@ 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"

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
Expand Down

0 comments on commit 2ca0e98

Please sign in to comment.