@patfm
I applaud the use of ChatGPT to get some starter code going and your willingness to explore Python and the Canvas API!
Just some comments:
1) The API call to get favorites actually doesn't work as written! Here's the documentation for favorites in Canvas.
You cannot specify a User ID like in other API endpoints to get that particular user's favorites. You can only use the self endpoint, which will pull your favorites.
So to get around this you can use API Masquerading.
This allows you to specify which Canvas user ID you want to act as, assuming you have the permissions to do so. What will then happen is that you'll basically act as them during the calls. This is equivalent to "Act as User"/masquerade in the UI.
2) get_current_term_id may work if your terms are unique for each school year/semester, but not so much if you use a SIS integration and your term page is insanely large. For example, at my K-12 district, I have distinct terms associated for each school, so instead of Q1, Q2, Q3, Q4, S1, S2, 23-24 terms that apply to all schools, I have terms like XYZ School - 23-24/YR...multiply this with 180+ schools and it gets to be a bit much.
In my case, I would pull the Terms CSV report from Canvas and just use Python to go through that CSV to find the "current terms" (all of them) and then do the favoriting code.
Hope this helps!