Simple MSD parser (rhythm game format)
Project description
msdparser
Simple MSD parser for Python. MSD is the underlying file format for many rhythm games, most notably both StepMania simfile formats (.sm and .ssc).
Installing
msdparser
is available on PyPI. During the current 2.0 beta phase, make sure to pass --pre
to pip
:
pip install --pre msdparser
Parsing
parse_msd
takes a named file
or string
argument and yields MSDParameter
instances:
>>> from msdparser import parse_msd
>>> with open('testdata/Springtime.ssc', 'r', encoding='utf-8') as simfile:
... for param in parse_msd(file=simfile):
... if param.key == 'NOTEDATA': break # stop at the first chart
... if not param.value: continue # hide empty values
... print(param.key, '=', repr(param.value))
...
VERSION = '0.83'
TITLE = 'Springtime'
ARTIST = 'Kommisar'
BANNER = 'springbn.png'
BACKGROUND = 'spring.png'
MUSIC = 'Kommisar - Springtime.mp3'
OFFSET = '-0.090'
SAMPLESTART = '105.760'
SAMPLELENGTH = '15'
SELECTABLE = 'YES'
DISPLAYBPM = '182'
BPMS = '0=181.685'
TIMESIGNATURES = '0=4=4'
TICKCOUNTS = '0=2'
COMBOS = '0=1'
SPEEDS = '0=1=0=0'
SCROLLS = '0=1'
LABELS = '0=Song Start'
Serializing
MSDParameter
instances stringify back to MSD. They can be created from a sequence of strings:
>>> from msdparser import MSDParameter
>>> pairs = [('TITLE', 'Springtime'), ('ARTIST', 'Kommisar')]
>>> for key, value in pairs:
... print(str(MSDParameter(key=key, value=value)))
...
#TITLE:Springtime;
#ARTIST:Kommisar;
Prefer to use MSDParameter
over interpolating the key/value pairs between #:;
characters yourself. The str()
implementation inserts escape sequences where required, preventing generation of invalid MSD.
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for msdparser-2.0.0b3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c77c9aa3c88144a76dfb59ad00c708e26b48d4408805cca5351068c9666a42 |
|
MD5 | e72065aad6ffab482d0784937162b019 |
|
BLAKE2b-256 | d03932931d92d76a1e59c0c4ea4996d9591c1e4dc2f32938a7222df23908ba19 |