im actually working on something very similiar, shame i only discovered this project like 3 minutes ago
I'm not really working on this actively anymore. Feel free to use whatever source code helps.
Edit: I am working on it again. Still, use whatever helps