Skip to content

Commit

Permalink
refactor(Video): Do not print "?"/"Unknown" values in str()
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Apr 14, 2024
1 parent dae83b0 commit 9ddd9ad
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions devine/core/tracks/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,20 @@ def __init__(self, *args: Any, codec: Video.Codec, range_: Video.Range, bitrate:
self.fps = FPS.parse(str(fps)) if fps else None

def __str__(self) -> str:
fps = f"{self.fps:.3f}" if self.fps else "Unknown"
return " | ".join(filter(bool, [
"VID",
f"[{self.codec.value}, {self.range.name}]",
"[" + (", ".join(filter(bool, [
self.codec.value if self.codec else None,
self.range.name
]))) + "]",
str(self.language),
f"{self.width}x{self.height} @ {self.bitrate // 1000 if self.bitrate else '?'} kb/s, {fps} FPS",
", ".join(filter(bool, [
" @ ".join(filter(bool, [
f"{self.width}x{self.height}" if self.width and self.height else None,
f"{self.bitrate // 1000} kb/s" if self.bitrate else None
])),
f"{self.fps:.3f} FPS" if self.fps else None
])),
self.edition
]))

Expand Down

0 comments on commit 9ddd9ad

Please sign in to comment.