I ported this script to python in my fork, if anyone is interested https://github.com/AnthonyMichaelTDM/grox