Skip to content

Commit

Permalink
Revert "Fix bitrate parsing for cross-platform environment"
Browse files Browse the repository at this point in the history
  • Loading branch information
lostanlen authored Mar 9, 2024
1 parent 3c18edf commit db27de1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions sox/file_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down

0 comments on commit db27de1

Please sign in to comment.