Closed DoTshavahn closed 4 years ago
@bbsan2k Thanks for initially creating this plugin!
This PR improves responsiveness of almost everything except initializing a stream, particularly though caching of the JWT API tokens.
Thanks again for those changes 😊 I'm gonna do some deeper review later, but can you please change the PR to merge to develop instead of master? I'm trying to use master only for releases.
Also: I didn't cache JWT previously because I didn't see any option to check whether it is still valid. Sometimes the API (for whatever reason) discarded my session in the middle of doing something.
@bbsan2k I've changed it to merge into develop.
As for the tokens, they are JSON Web Tokens (JWT). JWTs contain information within them, which can be read when they are decoded.
You can take the token text (without the 'JWT ' prefix) and use the JWT online debugger to decode it.
There are a few standard fields that a decoded token can have. Of note to validity times:
I implemented a system where the session/social tokens are decoded with PyJWT, and are cached and reused if their exp time is over 24 hours in the future.
For API caching, the F1TV API returns various cache control headers in its responses that can be used to cache responses.
I use the Kodi script.library.cache library to cache the API responses and tokens based off those bits of information.
Ok, just looked into it. Wow - good stuff 👍 Still - where did you get the pyjwt kodi addon from? I'm not sure it is available in the kodi addon repository - but I may also be mistaken.
PyJWT is in the Kodi repo: https://kodi.wiki/view/Add-on:Pyjwt
I've used that module in other Python projects, and was glad to find it in the repo once I saw that the APIs return JWTs.