Building a TV Server on a Synology NAS (Updated)

Work Environment

NAS:  Synology DS216+II with DSM 6.1.7-15284

Before you begin:

Enable SSH.

If you have a battery backup unit then enable UPS.

You will need to donate $20 to http://mc2xml.awardspace.info to get a version of the software that will run on your Synology if it uses an ARM processor and won’t run the standard x86 version that you can download from the site. The DS216+II in this tutorial has an Intel x86 / x64 processor so the standard x86 version will work just fine.

You will also need a subscription to Schedules Direct.

Add SynoCommunity to your package sources. Install the latest version of Tvheadend. You might need to enable beta versions to get the latest version of the software.

Create “public” Windows Share folder and make sure sc-tvheadend user has read access to it.

SSH into your Synology and create the following scripts.

/volume1/public/tv_grab_file

#!/bin/sh
# tv_grab_file for local XMLTV file
dflag=
vflag=
cflag=
if [ $# = 0 ]
then
cat /volume1/public/xmltv.xml
exit 0
fi

for arg
do
delim=""
case "$arg" in
#translate --gnu-long-options to -g (short options)
--description) args="${args}-d ";;
--version) args="${args}-v ";;
--capabilities) args="${args}-c ";;
#pass through anything else
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
args="${args}${delim}${arg}${delim} ";;
esac
done

eval set -- $args

while getopts "dvc" option
do
case $option in
d) dflag=1;;
v) vflag=1;;
c) cflag=1;;
\?) printf "unknown option: -%s\n" $OPTARG
printf "Usage: %s: [--description] [--version] [--capabilities] \n" $(basename $0)
exit 2
;;
esac >&2
done

if [ "$dflag" ]
then
printf "Local"
fi
if [ "$vflag" ]
then
printf "1.0\n"
fi
if [ "$cflag" ]
then
printf "baseline\n"
fi

exit 0

Create a symlink:
sudo ln -s /volume1/public/tv_grab_file /usr/bin/tv_grab_file

Change permissions and make the file executable:
sudo chmod 0755 /usr/bin/tv_grab_file
sudo chmod +x /usr/bin/tv_grab_file

/volume1/public/grab_listings

/volume1/public/mc2xml -T [username]:[password] -D /volume1/public/xmltv.dat -o /volume1/public/xmltv.xml

Make the file executable:
sudo chmod +x /volume1/public/grab_listings
sudo chmod 777 /volume1/public/grab_listings

Copy mc2xml to /volume1/public folder and make executable.

/etc/crontab

0       23       *       *       *       root    /volume1/public/grab_listings

Restart Cron:
sudo synoservice --restart crond