From db27de1a65fdd5bcf00edd2268489e57834ae569 Mon Sep 17 00:00:00 2001 From: Vincent Lostanlen Date: Sat, 9 Mar 2024 17:22:16 +0100 Subject: [PATCH] Revert "Fix bitrate parsing for cross-platform environment" --- sox/file_info.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sox/file_info.py b/sox/file_info.py index 8317724..3fb48f9 100644 --- a/sox/file_info.py +++ b/sox/file_info.py @@ -56,17 +56,13 @@ def bitrate(input_filepath: Union[str, Path]) -> Optional[float]: validate_input_file(input_filepath) output = soxi(input_filepath, 'B') # The characters below stand for kilo, Mega, Giga, etc. - # greek_prefix might not be the last character in string in cross platform - # environment - \r\n - greek_prefixes = '\0KMGTPEZY' - greek_index = [n for n, p in enumerate(greek_prefixes) if p in output.upper()] + greek_prefixes = '\0kMGTPEZY' if output == "0": logger.warning("Bit rate unavailable for %s", input_filepath) return None - elif greek_index: - assert len(greek_index) == 1 - multiplier = 1000.0**greek_index[0] - return float(output[:greek_index[0]])*multiplier + elif output[-1] in greek_prefixes: + multiplier = 1000.0**(greek_prefixes.index(output[-1])) + return float(output[:-1])*multiplier else: return float(output[:-1])