Script for collecting information about items from Minecraft mods and optionally downloading their images with multi-threaded processing.
This script collects information about items from specified Minecraft mods by:
- Reading mod list from mods_data.json or command line arguments
- Searching for mod items via the Minecraft Wiki API
- Collecting item details and associated images
- Saving data to a single JSON file
- Optionally downloading images to a local directory
- Multi-threaded processing at three levels:
- Parallel mod processing
- Parallel item processing within each mod
- Parallel image processing for each item
- Configurable number of worker threads
- Automatic rate limiting with configurable delays
- Comprehensive error handling and logging
- Progress tracking and detailed statistics
- Supports both individual mod processing and batch processing
- Automatic file naming and sanitization
- Checks for existing mod data to avoid duplicates
- Python 3.6+
- Required packages:
- requests
- concurrent.futures (built-in)
- logging (built-in)
The script uses the following configurable settings:
MAX_WORKERS
: Maximum number of concurrent threads (default: 10)DELAY_BETWEEN_REQUESTS
: Delay between API requests in seconds (default: 1)
The script generates a JSON file with the following structure:
{
"mods": [
{
"mod_name": "ModName",
"items": [
{
"images": [
{
"name": "Item Name",
"url": "https://...",
"localPath": "mod_items_data/ItemName_hash.png"
}
]
}
]
}
]
}
python scripts/get_mod_items.py --mods ModName
python scripts/get_mod_items.py --from-json
python scripts/get_mod_items.py --from-json --download --workers 15
python scripts/get_mod_items.py --mods ModName1 ModName2 --download
--mods
: List of mod names to process (optional)--from-json
: Read mod list from mods_data.json--download
: Enable image downloading--workers
: Number of worker threads (default: 10)
mod_items_data.json
: Main data file containing all mod informationmod_items_data/
: Directory containing downloaded images (when using --download)mod_items.log
: Detailed log file with operation information
The script provides detailed statistics after completion:
- Total number of processed mods
- Successfully processed mods
- Failed mod processing attempts
- Processing time and other metrics
- Images are only downloaded when using the --download flag
- Existing mod data is skipped to avoid duplicates
- Image filenames are generated using item name and URL hash
- All paths are automatically sanitized for cross-platform compatibility
- The script implements rate limiting to avoid overwhelming the API