I see you posted the same question on the "StackOverflow" forum back in March, 2020. You indicated that the solution offered was good and it worked. Did it break or are you needing additional info? I assume it was you because the question was worded the same as this one. If I'm wrong, my bad.
I seriously doubt you will find an answer here, although some of us are coders, it's unlikely we are doing this kind of programming. We are users of Canon products.
Best of luck figuring this out