SVG Decompressor is a Python tool designed to decode, decompress, and parse SVG-encoded files generated by Path of Building (PoE2). It converts compressed SVG data into a structured JSON format, enabling further analysis and integration into other systems. Additionally, the project includes Lua scripts for processing node mappings and passive tree data with provided files.
-
Decode and Decompress:
- Reads a base64-encoded and zlib-compressed SVG string.
- Applies different decompression strategies (with varying
wbits
parameters) for robustness.
-
Parse XML:
- Converts the decompressed SVG string into an XML structure.
-
Data Extraction:
-
Extracts critical information including:
- Player Info: Level, Class, and Ascendancy.
- Player Stats: A set of key-value pairs.
- Passive Skill Tree: Extracts node data from a comma-separated list.
- Skills: Retrieves skills and details of socketed gems.
- Items: Parses item details (name, type, rarity, level, quality, sockets, rune, and modifiers).
-
-
Data Cleaning and Output:
- Recursively removes
None
values from the data. - Saves the structured data into a JSON file (
decompressed_build.json
).
- Recursively removes
-
Lua Integration:
- Provides Lua scripts (
NodeIndexMapping.lua
andtree.lua
) to further process or map passive tree node data. - Includes a function to extract node details from Lua-based node definitions.
- Provides Lua scripts (
PoB-SVG-Decompressor-main/
├── .gitignore # Git ignore file
├── Example/
│ ├── build.txt # Example file with base64-encoded, compressed SVG data
│ └── structured_build.json # Sample output JSON from the decompression process
├── LICENSE # MIT License file
├── NodeIndexMapping.lua # Lua script for mapping passive tree node indices
├── README.md # This README file
├── svg_decompressor.py # Main Python script handling decompression, parsing, and JSON output
└── tree.lua # Additional Lua script likely related to passive tree processing
-
Robust Decoding & Decompression:
Uses multiplewbits
configurations (15
,-15
, and31
) to handle a variety of compressed data formats reliably. -
Comprehensive XML Parsing:
Extracts detailed game-related data:- Player Info: Automatically determines player level, class, and ascendancy from the XML.
- Player Stats: Compiles player statistics into a dictionary.
- Passive Skill Tree: Retrieves node IDs from a comma-separated string.
- Skills and Gems: Captures skills along with the details of socketed gems (e.g., name, level, quality, and enabled status).
- Items: Parses multi-line text to extract item attributes such as name, type, rarity, item level, quality, and other modifiers.
-
Data Cleaning:
Implements a recursive function to removeNone
values from nested dictionaries and lists while preserving empty structures. -
Lua Node Extraction:
Includes functions to extract node definitions from Lua files. The Lua scripts help map node indices to skill names and associated stats, enabling enhanced processing of the passive tree.
-
Prerequisites:
Ensure you have Python 3 installed. -
Run the .exe
Just download the svg_decompressor.exe -
Or Clone the Repository:
git clone https://github.com/your-username/PoB-SVG-Decompressor.git cd PoB-SVG-Decompressor
-
Prepare Your Data:
Place your base64-encoded and compressed SVG data into a .txt file. An example (build.txt
) is provided in theExample/
directory. -
Run the .exe file
You will need the file path to your build.txt. -
Or Run the Decompression Script:
python svg_decompressor.py
- The script reads the SVG data, decompresses and decodes it, and then parses the XML structure.
- It extracts player information, stats, passive tree data, skills (and gems), and items.
- The final structured output is saved as
structured_build.json
.
-
Lua Scripts:
The Lua scripts (NodeIndexMapping.lua
andtree.lua
) are provided for additional processing.
This project uses only Python's built-in libraries:
base64
os
zlib
json
xml.etree.ElementTree
re
No third-party packages are required.
-
Decoding & Decompression:
The functiondecompress_svg(encoded)
handles base64 decoding and attempts decompression using three differentwbits
values. -
XML Data Extraction:
Several helper functions are defined:extract_player_info(xml_root)
extract_player_stats(xml_root)
extract_passive_tree(xml_root)
extract_skills(xml_root)
extract_items(xml_root)
Each function targets specific sections of the XML to pull out game-related data.
-
Data Cleaning:
Theremove_nulls(d)
function ensures that the final JSON output is free ofNone
values. -
Output:
The structured data is saved asstructured_build.json
using thesave_json(data, output_file)
function. -
Lua Node Extraction:
The functionextract_nodes_as_list(filename)
in the Python script reads and processes Lua files to extract passive tree node definitions, utilizing regular expressions to parse node details.
This project is licensed under the MIT License – see the LICENSE file for details.
Contributions are welcome! Please open an issue to discuss major changes before submitting a pull request.
For questions, suggestions, or further information, please open an issue on GitHub or contact the creator:
Axel Bouchaud--Roche
GitHub Profile