Have you looked at this?
I haven’t used it, but it’s on my list of things to look at when I have time. Sounds like it might be useful for what you are trying to do.