I hacked together a dirty bash script that sends notifications when new stream are started. It monitors the channels-dvr.log for connections to live tv and recorded tv.
Requirements need:
jq is a lightweight and flexible command-line JSON processor
Boxcar Universal Push Notification Platform Or other cmdlline based notification service
Bash Shell runtime environment
Basically I just kicked the script off and let it run.
#!/bin/bash
activitydb=$(curl -s http://LOCAL_IP_TO_DVR:8089/dvr | jq '.activity|keys[]')
echo ${activitydb}
tail -Fn0 "/PATH-TO/data/channels-dvr.log" | \
while read line ; do
echo "$line" | egrep -s "Opened connection to | Starting transcoder for file"
if [ $? = 0 ]
then
sleep 1
tempKeys=$(curl -s http://LOCAL_IP_TO_DVR:8089/dvr | jq '.activity|keys[]')
#echo ${tempKeys}
for key in ${tempKeys}
do
if [[ ! ${activitydb[@]} =~ ${key} && ( ${key} =~ "6-stream-" || ${key} =~ "7-file" || ${key} =~ "0-job-" ) ]]; then
#echo ${key}
activitydb+=" ${key}"
TITLE="$(curl -s http://LOCAL_IP_TO_DVR:8089/dvr | jq '.activity['${key}']')"
TITLE=${TITLE//\"}
MESSAGE=""
BOXCAR_SOUND=echo
BOXCAR_ACCESS_TOKEN=*******
/usr/bin/curl -d "user_credentials=${BOXCAR_ACCESS_TOKEN}" \
-d "notification[title]=${TITLE}" \
-d "notification[long_message]=${MESSAGE}" \
-d "notification[source_name]=Channels DVR" \
-d "notification[sound]=${BOXCAR_SOUND}" \
https://new.boxcar.io/api/notifications > /dev/null 2>&1
fi
done
#echo ${activitydb}
fi
echo "$line" | egrep -s "Closed connection to | Stopping transcoder session file"
if [ $? = 0 ]
then
sleep 1
activitydb=$(curl -s http://LOCAL_IP_TO_DVR:8089/dvr | jq '.activity|keys[]')
#echo ${activitydb}
fi
done