Kodi Community Forum

Full Version: Email Notification Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For a while now, I've wanted a simple system to send me (and family members) scheduled notifications/updates of new content added to Kodi. Unfortunately, I found most of the notification mechanisms didn't really give me what I wanted. So I put together a simple script to do the job.

Pre-requisites

It's written for bash and has been tested on Debian Linux, but it will probably work on any Linux system and maybe on BSD and OSX. Data is stored in a local database, so a copy of sqlite3 is needed, and jq is used to parse the JSON data returned by Kodi. And, optionally, if you want to have the updates automatically emailed to you by the script, you'll need mpack. These should all be available in the repository of your preferred Linux distro.

How it Works

The script queries Kodi, looking for any new movies and/or shows added over a specified period. Any content it finds is logged in a local database, and a summary of the new content is put into an html file which can, optionally, be sent to a specified recipient. A copy of some of the data is stored locally, so that in the event that you accidentally hose your Kodi library, rebuilding it from scratch won't suddenly result in the script finding a bunch of "new" content.

The script was designed to be run on a file server, querying a remote Kodi instance. But there's no reason why it can't run on the same system that Kodi is installed on. To the best of my knowledge, there's also no reason why you couldn't poll multiple Kodi systems, with the email containing a combined summary of the new content found.

More details, along with the script itself, can be found on github.

Examples

./differ -d 1 -s 192.168.1.5 -m [email protected]

This would poll your Kodi instance, on the address 192.168.1.5, and look for any content that was new in the last day, emailing the results to [email protected]

./differ -d 7 -s openelec.local -U

This would poll your Kodi instance (in this case OpenELEC), at the address openelec.local, and find any new content from the last week. An update email will be prepared, but not emailed (you could then email it using another script if you liked). Before polling, the -U will specify that you Kodi instance does a library update first.

./differ -s 192.168.1.10

This would poll your Kodi instance, at the address 192.168.1.10, for ALL the content, but not email any update. Basically, this is the command you'd run the first time, to create a local library.

Personally, I've scheduled the script to run (using cron) every day around 5pm. It gives me all the content added to the server in the last day, in an email I can read on my train ride home.