Episode monitor flag (status) add-on for Kodi

I wrote a bash script that does that. Runs on the server sonarr is. Fetches the last 25 episodes on kodi using api, then filter by watched (play count >0) finally then using the sonarr api sets unmonitor. This prevents getting propers when you alrwady watched an episode.
Runs in Cron every hour, not very efficient but does the job.
I use it in the server because I have a firetv and to have bash there would mean to root the device, also the script uses jq binary to filter json.