garcia / simfile

A modern simfile parsing & editing library for Python 3
MIT License
62 stars 7 forks source link

Missplaced Commas in BPMs cause ValueError #38

Closed bjfranks closed 4 months ago

bjfranks commented 1 year ago

Processing one erroneous song causes a ValueError. Namely, there are too many commas in the bpms, which then get split and end up in empty strings which cannot be split by = and unpacked into two values. Here is one of the errors, it's caused for all charts because it's in the main bpms.

Miss You 0
Traceback (most recent call last):
  File "...", line 8, in calculate_statistics
    timing_data = TimingData(simfileInstance, simfileInstance.charts[chart])
  File "D:\Meatball\venv\lib\site-packages\simfile\timing\__init__.py", line 210, in __init__
    self.bpms = BeatValues.from_str(simfile_or_chart.bpms)
  File "D:\Meatball\venv\lib\site-packages\simfile\timing\__init__.py", line 174, in from_str
    beat, value = row.strip().split("=")
ValueError: not enough values to unpack (expected 2, got 1)

Also, here is the offending part of the file, which is attached below:

#BPMS:0.000000=132.000000
,172.000000=99.000000
,172.250000=49.500000
,172.500000=66.000000
,205.000000=-132,
,209.000000=132,
,213.000000=-132,
,217.000000=132,
,221.000000=-132,
,225.000000=132,
,229.000000=-132,
,232.875000=132
;

missyou.zip

garcia commented 4 months ago

This is now fixed on the v3 branch for non-strict parsed simfiles.

This is a duplicate of #4, so will follow up there once v3 is stable.