def _getBpm(self):
from decimal import Decimal, ROUND_HALF_UP, InvalidOperation
bpm = None
if frames.BPM_FID in self.frame_set:
bpm_str = self.frame_set[frames.BPM_FID][0].text or u"0"
try:
# Round floats since the spec says this is an integer. Python3
# changed how 'round' works, hence the using of decimal
bpm = int(Decimal(bpm_str).quantize(1, ROUND_HALF_UP))
except (InvalidOperation, ValueError) as ex:
log.warning(ex)
return bpm
评论列表
文章目录