Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to control Kodi
#!/bin/bash
# xbmc
# Parameters:
# UL - update library
# CL - clean library
# UAL - update audio library
# CAL - clean audio libary
# QUIT - Quit XBMC
input="$1"
# 138
ip="192.168.1.141"
user="kodi"
pass="kodi"
port="8081"
if [ $(echo "$input" |tr [:upper:] [:lower:]) == "ul" ]; then
#Scan New Videos to the Library
curl -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\", \"id\": \"mybash\"}" -H "content-type:application/json" http://$user:$pass@$ip:$port/jsonrpc
elif [ $(echo "$input" |tr [:upper:] [:lower:]) == "cl" ]; then
#Cleanup the library and remove old missing content
curl -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Clean\", \"id\": \"mybash\"}" -H "content-type:application/json" http://$user:$pass@$ip:$port/jsonrpc
elif [ $(echo "$input" |tr [:upper:] [:lower:]) == "ual" ]; then
#Scan in New music Albums
curl -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"AudioLibrary.Scan\", \"id\": \"mybash\"}" -H "content-type:application/json" http://$user:$pass@$ip:$port/jsonrpc
elif [ $(echo "$input" |tr [:upper:] [:lower:]) == "cal" ]; then
#Cleanup and remove missing albums
curl -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"AudioLibrary.Clean\", \"id\": \"mybash\"}" -H "content-type:application/json" http://$user:$pass@$ip:$port/jsonrpc
elif [ $(echo "$input" |tr [:upper:] [:lower:]) == "quit" ]; then
#Quit XBMC
curl -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"Application.Quit\", \"id\": \"1\"}" -H "content-type:application/json" http://$user:$pass@$ip:$port/jsonrpc
elif [ $(echo "$input" |tr [:upper:] [:lower:]) == "q" ]; then
#Quit XBMC
curl -i -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"Application.Quit\", \"id\": \"1\"}" -H "content-type:application/json" http://$user:$pass@$ip:$port/jsonrpc
else
clear
echo ""
echo "Please enter a parameter from below to update/clean the video/audio library."
echo ""
echo "xbmc-update.sh PARAMATER"
echo ""
echo "Parameters:"
echo " UL - update library"
echo " CL - clean library"
echo " UAL - update audio library"
echo " CAL - clean audio library"
echo " QUIT or Q - quit XBMC"
echo ""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.