I am sorry to say that this platform is used to help each other out and not a platform to sell your product. Try other software selling platforms like two-cows etc to sell your product. Thanks excellent salesmanship
You didn't ask for help, though. You asked for someone to write a (complex) script for you, and seeing it's not a simple task I thought it relevant to mention this tool I've created that does exactly that. If you don't want to buy it feel free to ignore my reply and write the code that does it yourself, but don't expect the people contributing here in their own free time to do it for you. Good luck.