https://github.com/axelbcr/pob-build-decompressor
This Python script decompresses a base64-encoded and zlib-compressed SVG file. It reads the encoded data from a .txt file, decodes and decompresses it, and then saves the resulting XML content into a .json file.
https://github.com/axelbcr/pob-build-decompressor
decompression-algorithm exe json pathofbuilding pathofexile pathofexile2 poe poe2 python svg xml
Last synced: about 2 months ago
JSON representation
This Python script decompresses a base64-encoded and zlib-compressed SVG file. It reads the encoded data from a .txt file, decodes and decompresses it, and then saves the resulting XML content into a .json file.
- Host: GitHub
- URL: https://github.com/axelbcr/pob-build-decompressor
- Owner: AxelBcr
- License: mit
- Created: 2025-03-02T14:26:53.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-16T13:14:04.000Z (about 2 months ago)
- Last Synced: 2025-03-16T14:24:10.697Z (about 2 months ago)
- Topics: decompression-algorithm, exe, json, pathofbuilding, pathofexile, pathofexile2, poe, poe2, python, svg, xml
- Language: Lua
- Homepage:
- Size: 7.82 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Build Decompressor
Build Decompressor is a Python tool designed to decode, decompress, and parse SVG-encoded files generated by **Path of Building (PoE2)**. It converts compressed the build 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.
## Overview
1. **Decode and Decompress:**
- Reads a base64-encoded and zlib-compressed SVG string.
- Applies different decompression strategies (with varying `wbits` parameters) for robustness.
2. **Parse XML:**
- Converts the decompressed SVG string into an XML structure.
4. **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).
5. **Data Cleaning and Output:**
- Recursively removes `None` values from the data.
- Saves the structured data into a JSON file (`decompressed_build.json`).
7. **Lua Integration:**
- Provides Lua scripts (`NodeIndexMapping.lua` and `tree.lua`) to further process or map passive tree node data.
- Includes a function to extract node details from Lua-based node definitions.## Project Structure
```
PoB-Build-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
├── build_decompressor.py # Main Python script handling decompression, parsing, and JSON output
└── tree.lua # Additional Lua script likely related to passive tree processing
```## Features
- **Robust Decoding & Decompression:**
Uses multiple `wbits` configurations (`15`, `-15`, and `31`) 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 remove `None` 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.## Installation
1. **Prerequisites:**
Ensure you have Python 3 installed.2. **Run the .exe**
Just download the build_decompressor.exe3. **Or Clone the Repository:**
```bash
git clone https://github.com/your-username/PoB-Build-Decompressor.git
cd PoB-Build-Decompressor
```
## Usage1. **Prepare Your Data:**
Place your base64-encoded and compressed SVG data into a **.txt** file. An example (`build.txt`) is provided in the `Example/` directory.2. **Run the .exe file**
You will need the **file path** to your build.txt.3. **Or Run the Decompression Script:**
```bash
python Build_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`.4. **Lua Scripts:**
The Lua scripts (`NodeIndexMapping.lua` and `tree.lua`) are provided for additional processing.## Dependencies
This project uses only Python's built-in libraries:
- `base64`
- `os`
- `zlib`
- `json`
- `xml.etree.ElementTree`
- `re`No third-party packages are required.
## Code Details
- **Decoding & Decompression:**
The function `decompress_svg(encoded)` handles base64 decoding and attempts decompression using three different `wbits` 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:**
The `remove_nulls(d)` function ensures that the final JSON output is free of `None` values.
- **Output:**
The structured data is saved as `structured_build.json` using the `save_json(data, output_file)` function.
- **Lua Node Extraction:**
The function `extract_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.## License
This project is licensed under the **MIT License** – see the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please open an issue to discuss major changes before submitting a pull request.
## Contact
For questions, suggestions, or further information, please open an issue on GitHub or contact the creator:
**Axel Bouchaud--Roche**
[GitHub Profile](https://github.com/AxelBcr)