llllllllll / slider

Utilities for working with osu! files and data
https://llllllllll.github.io/slider/index.html
GNU Lesser General Public License v3.0
39 stars 17 forks source link

Error if the Bookmarks field is present but empty #117

Open 120-cell opened 11 months ago

120-cell commented 11 months ago

Some beatmap files contain a line for Bookmarks without any values like this:

[Editor]
Bookmarks:

Presumably they have been manually edited, since the editor will not generate a line for bookmarks if there are none. Here's the map where I found the issue: Sasaki Sayaka - Golden Mission (yuzu__rinrin) [Futsuu].osu.txt

The game will still accept such files, but the parser throws an error:

Exception has occurred: ValueError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
field 'Bookmarks' in section 'Editor' should be an int list, got ''
  File "/usr/lib/python3.11/site-packages/slider/beatmap.py", line 1115, in _get_as_int_list
    return [int(e.strip()) for e in v.split(',')]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/slider/beatmap.py", line 1115, in <listcomp>
    return [int(e.strip()) for e in v.split(',')]
            ^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

  File "/usr/lib/python3.11/site-packages/slider/beatmap.py", line 1117, in _get_as_int_list
    raise ValueError(
  File "/usr/lib/python3.11/site-packages/slider/beatmap.py", line 2600, in parse
    timedelta(milliseconds=ms) for ms in _get_as_int_list(
                                         ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/slider/beatmap.py", line 2398, in from_file
    return cls.parse(file.read())
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/slider/beatmap.py", line 2349, in from_path
    return cls.from_file(file)
           ^^^^^^^^^^^^^^^^^^^
ValueError: field 'Bookmarks' in section 'Editor' should be an int list, got ''