Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix bitrate parsing for cross-platform environment" #164

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading