{"id":26059967,"url":"https://github.com/axelbcr/pob-svg-decompressor","last_synced_at":"2025-03-08T13:48:47.756Z","repository":{"id":280295402,"uuid":"941535726","full_name":"AxelBcr/PoB-SVG-Decompressor","owner":"AxelBcr","description":"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 .xml and .json files.","archived":false,"fork":false,"pushed_at":"2025-03-02T14:55:41.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T15:33:17.429Z","etag":null,"topics":["decompression-algorithm","json","pathofbuilding","pathofexile","pathofexile2","python","svg","xml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AxelBcr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-02T14:26:53.000Z","updated_at":"2025-03-02T14:56:05.000Z","dependencies_parsed_at":"2025-03-02T15:33:21.220Z","dependency_job_id":"8e7769ca-c820-4895-99b9-e05ef33f4d49","html_url":"https://github.com/AxelBcr/PoB-SVG-Decompressor","commit_stats":null,"previous_names":["axelbcr/pob2-svg-decompressor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxelBcr%2FPoB-SVG-Decompressor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxelBcr%2FPoB-SVG-Decompressor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxelBcr%2FPoB-SVG-Decompressor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxelBcr%2FPoB-SVG-Decompressor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AxelBcr","download_url":"https://codeload.github.com/AxelBcr/PoB-SVG-Decompressor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242559203,"owners_count":20149326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decompression-algorithm","json","pathofbuilding","pathofexile","pathofexile2","python","svg","xml"],"created_at":"2025-03-08T13:48:47.027Z","updated_at":"2025-03-08T13:48:47.747Z","avatar_url":"https://github.com/AxelBcr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SVG Decompressor\n\nSVG 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.\n\n## Overview\n\n1. **Decode and Decompress:**    \n   - Reads a base64-encoded and zlib-compressed SVG string.\n   - Applies different decompression strategies (with varying `wbits` parameters) for robustness.  \n2. **Parse XML:**\n   \n   - Converts the decompressed SVG string into an XML structure.\n     \n4. **Data Extraction:**  \n   - Extracts critical information including:\n     \n     - **Player Info:** Level, Class, and Ascendancy.\n     - **Player Stats:** A set of key-value pairs.\n     - **Passive Skill Tree:** Extracts node data from a comma-separated list.\n     - **Skills:** Retrieves skills and details of socketed gems.\n     - **Items:** Parses item details (name, type, rarity, level, quality, sockets, rune, and modifiers).\n       \n5. **Data Cleaning and Output:**\n   \n   - Recursively removes `None` values from the data.\n   - Saves the structured data into a JSON file (`decompressed_build.json`).\n     \n7. **Lua Integration:**\n   \n   - Provides Lua scripts (`NodeIndexMapping.lua` and `tree.lua`) to further process or map passive tree node data.\n   - Includes a function to extract node details from Lua-based node definitions.\n\n## Project Structure\n\n```\nPoB-SVG-Decompressor-main/\n├── .gitignore                   # Git ignore file\n├── Example/\n│   ├── build.txt                # Example file with base64-encoded, compressed SVG data\n│   └── structured_build.json    # Sample output JSON from the decompression process\n├── LICENSE                      # MIT License file\n├── NodeIndexMapping.lua         # Lua script for mapping passive tree node indices\n├── README.md                    # This README file\n├── svg_decompressor.py          # Main Python script handling decompression, parsing, and JSON output\n└── tree.lua                     # Additional Lua script likely related to passive tree processing\n```\n\n## Features\n\n- **Robust Decoding \u0026 Decompression:**  \n  Uses multiple `wbits` configurations (`15`, `-15`, and `31`) to handle a variety of compressed data formats reliably.\n  \n- **Comprehensive XML Parsing:**  \n  Extracts detailed game-related data:\n  - **Player Info:** Automatically determines player level, class, and ascendancy from the XML.\n  - **Player Stats:** Compiles player statistics into a dictionary.\n  - **Passive Skill Tree:** Retrieves node IDs from a comma-separated string.\n  - **Skills and Gems:** Captures skills along with the details of socketed gems (e.g., name, level, quality, and enabled status).\n  - **Items:** Parses multi-line text to extract item attributes such as name, type, rarity, item level, quality, and other modifiers.\n  \n- **Data Cleaning:**  \n  Implements a recursive function to remove `None` values from nested dictionaries and lists while preserving empty structures.\n  \n- **Lua Node Extraction:**  \n  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.\n\n## Installation\n   \n1. **Prerequisites:**  \n   Ensure you have Python 3 installed.\n\n2. **Run the .exe**   \n   Just download the svg_decompressor.exe   \n\n3. **Or Clone the Repository:**\n\n   ```bash\n   git clone https://github.com/your-username/PoB-SVG-Decompressor.git\n   cd PoB-SVG-Decompressor\n   ```\n   \n## Usage\n\n1. **Prepare Your Data:**  \n   Place your base64-encoded and compressed SVG data into a **.txt** file. An example (`build.txt`) is provided in the `Example/` directory.   \n\n2. **Run the .exe file**   \n   You will need the **file path** to your build.txt.   \n\n3. **Or Run the Decompression Script:**\n\n   ```bash\n   python svg_decompressor.py\n   ```\n\n   - The script reads the SVG data, decompresses and decodes it, and then parses the XML structure.\n   - It extracts player information, stats, passive tree data, skills (and gems), and items.\n   - The final structured output is saved as `structured_build.json`.\n\n4. **Lua Scripts:**  \n   The Lua scripts (`NodeIndexMapping.lua` and `tree.lua`) are provided for additional processing.\n\n## Dependencies\n\nThis project uses only Python's built-in libraries:\n- `base64`\n- `os`\n- `zlib`\n- `json`\n- `xml.etree.ElementTree`\n- `re`\n\nNo third-party packages are required.\n\n## Code Details\n\n- **Decoding \u0026 Decompression:**  \n  The function `decompress_svg(encoded)` handles base64 decoding and attempts decompression using three different `wbits` values.\n  \n- **XML Data Extraction:**  \n  Several helper functions are defined:\n  - `extract_player_info(xml_root)`\n  - `extract_player_stats(xml_root)`\n  - `extract_passive_tree(xml_root)`\n  - `extract_skills(xml_root)`\n  - `extract_items(xml_root)`\n  \n  Each function targets specific sections of the XML to pull out game-related data.\n  \n- **Data Cleaning:**  \n  The `remove_nulls(d)` function ensures that the final JSON output is free of `None` values.\n  \n- **Output:**  \n  The structured data is saved as `structured_build.json` using the `save_json(data, output_file)` function.\n  \n- **Lua Node Extraction:**  \n  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.\n\n## License\n\nThis project is licensed under the **MIT License** – see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please open an issue to discuss major changes before submitting a pull request.\n\n## Contact\n\nFor questions, suggestions, or further information, please open an issue on GitHub or contact the creator:\n\n**Axel Bouchaud--Roche**  \n[GitHub Profile](https://github.com/AxelBcr)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelbcr%2Fpob-svg-decompressor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxelbcr%2Fpob-svg-decompressor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelbcr%2Fpob-svg-decompressor/lists"}