
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
A comprehensive Python module for parsing and manipulating LiveSplit .lss
files. This module converts XML-based LSS files into easy-to-use Python objects, allowing for programmatic analysis and manipulation of speedrun data.
load_lss_file()
and save_lss_file()
This module requires Pydantic. Install dependencies:
pip install pydantic
Then copy the lss_parser.py
file to your project directory or install it as a module.
import lss_parser
import lss_parser
# Load a LiveSplit file
run = lss_parser.load_lss_file("my_speedrun.lss")
# Access basic information
print(f"Game: {run.game_name}")
print(f"Category: {run.category_name}")
print(f"Total Attempts: {run.attempt_count}")
print(f"Number of Segments: {len(run.segments)}")
# Modify the run data
run.game_name = "Modified Game Name"
run.category_name = "Any% Modified"
# Save the modified run
lss_parser.save_lss_file(run, "modified_speedrun.lss")
The module provides several Pydantic models to represent LSS file structure:
Run
- Main Containergame_name
: Name of the gamecategory_name
: Speedrun categoryversion
: LSS file versionattempt_count
: Total number of attemptssegments
: List of segments (splits)attempt_history
: List of all attemptsmetadata
: Platform, region, and other metadataauto_splitter_settings
: Auto-splitter configurationSegment
- Individual Splitsname
: Segment nameicon
: Icon path/datasplit_times
: List of split times with different timing methodsbest_segment_time
: Best time for this segmentsegment_history
: Historical times for this segmentAttempt
- Run Attemptsid
: Unique attempt identifierstarted
: Start time/dateended
: End time/datetime
: Timing data (real time, game time, pause time)Time
- Timing Informationreal_time
: Real world timegame_time
: In-game timepause_time
: Paused timeThe module leverages Pydantic's powerful features:
import lss_parser
# Automatic type conversion
time = lss_parser.Time(real_time=123) # Converts to "123"
print(time.real_time) # "123"
# Validation on assignment
run = lss_parser.Run(game_name="Test Game")
run.attempt_count = "42" # Automatically converted to int
# Export to JSON
run = lss_parser.load_lss_file("speedrun.lss")
run_dict = run.model_dump() # or run.dict() for older Pydantic versions
# Import from JSON
run_data = {...} # JSON data
run = lss_parser.Run(**run_data)
# IDE support with type hints
def analyze_run(run: lss_parser.Run) -> None:
for segment in run.segments: # Full IDE autocomplete
print(f"Segment: {segment.name}")
print(f"Best time: {segment.best_segment_time.real_time}")
import lss_parser
# Load the file
run = lss_parser.load_lss_file("my_speedrun.lss")
# Find completed attempts
completed_attempts = [a for a in run.attempt_history if a.time.real_time]
print(f"Completed {len(completed_attempts)} out of {len(run.attempt_history)} attempts")
# Analyze segment times
for segment in run.segments:
print(f"{segment.name}: Best {segment.best_segment_time.real_time or 'N/A'}")
# Get personal best
pb_attempts = [a for a in completed_attempts if a.time.real_time]
if pb_attempts:
best_time = min(pb_attempts, key=lambda x: x.time.real_time)
print(f"Personal Best: {best_time.time.real_time}")
import lss_parser
# Create a new run
new_run = lss_parser.Run(
game_name="My Game",
category_name="Any%"
)
# Add segments
segments = [
lss_parser.Segment(
name="Level 1",
best_segment_time=lss_parser.Time(real_time="00:01:30.0000000")
),
lss_parser.Segment(
name="Level 2",
best_segment_time=lss_parser.Time(real_time="00:02:15.0000000")
),
lss_parser.Segment(
name="Boss",
best_segment_time=lss_parser.Time(real_time="00:03:45.0000000")
)
]
new_run.segments = segments
# Add metadata
new_run.metadata.platform = "PC"
new_run.metadata.region = "USA"
# Save the new run
lss_parser.save_lss_file(new_run, "new_speedrun.lss")
import lss_parser
# Load existing file
run = lss_parser.load_lss_file("existing_run.lss")
# Modify segment names
for segment in run.segments:
segment.name = f"Modified {segment.name}"
# Add a new segment
new_segment = lss_parser.Segment(
name="New Final Boss",
best_segment_time=lss_parser.Time(real_time="00:05:00.0000000")
)
run.segments.append(new_segment)
# Update attempt count
run.attempt_count = len(run.attempt_history)
# Save changes
lss_parser.save_lss_file(run, "modified_run.lss")
load_lss_file(file_path: Union[str, Path]) -> Run
Loads and parses an LSS file into a Run object.
Parameters:
file_path
: Path to the .lss fileReturns:
Run
object containing all parsed dataRaises:
FileNotFoundError
: If the file doesn't existValueError
: If the file is not a valid LSS filexml.etree.ElementTree.ParseError
: If the XML is malformedsave_lss_file(run: Run, file_path: Union[str, Path]) -> None
Saves a Run object to an LSS file.
Parameters:
run
: Run object to savefile_path
: Path where to save the .lss fileRaises:
ValueError
: If the file path is invalidAll data models are implemented using Pydantic's BaseModel
and include:
The module includes comprehensive error handling:
import lss_parser
try:
run = lss_parser.load_lss_file("nonexistent.lss")
except FileNotFoundError:
print("File not found!")
except ValueError as e:
print(f"Invalid file: {e}")
except Exception as e:
print(f"Parse error: {e}")
The module includes comprehensive tests. Run them with:
python test_parser.py
See demo.py
for a comprehensive demonstration of all features:
python demo.py
This parser supports LiveSplit LSS files version 1.7.0 and should be compatible with other versions. The parser handles:
This module is provided as-is for educational and personal use. It is not affiliated with LiveSplit or the LiveSplit development team.
This is a complete, self-contained module designed for parsing LSS files. Feel free to extend it for your specific needs.
FAQs
A Python module for parsing and manipulating LiveSplit .lss files
We found that lss-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.