#!/bin/bash

# Change these values to yours if you aren't just blithely using Kodi's default settings
USERNAME="kodi"
PASSWORD="kodi"
HOSTNAME="localhost"
PORT="8080"

# First, we scan for new items
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://${USERNAME}:${PASSWORD}@${HOSTNAME}:${PORT}/jsonrpc
curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://${USERNAME}:${PASSWORD}@${HOSTNAME}:${PORT}/jsonrpc
# Now, we clean up anything that's no longer available
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://${USERNAME}:${PASSWORD}@${HOSTNAME}:${PORT}/jsonrpc
curl --data-binary '{ "jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": "mybash"}' -H 'content-type: application/json;' http://${USERNAME}:${PASSWORD}@${HOSTNAME}:${PORT}/jsonrpc
