From 33901d2a6e7111442565956fe51f96c0c02c617c Mon Sep 17 00:00:00 2001
From: Andrew Ruthven <andrew@etc.gen.nz>
Date: Sat, 11 Jun 2022 19:59:10 +1200
Subject: [PATCH] Allow an external configuration file

---
 bin/do_mhegepgsnoop      | 15 +++++++++------
 etc/do_mhegepgsnoop.conf | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 6 deletions(-)
 create mode 100644 etc/do_mhegepgsnoop.conf

diff --git a/bin/do_mhegepgsnoop b/bin/do_mhegepgsnoop
index 63434bd..01f14ac 100644
--- a/bin/do_mhegepgsnoop
+++ b/bin/do_mhegepgsnoop
@@ -1,23 +1,26 @@
 #!/bin/bash
 
+CONFIG_FILE=/etc/mythtv-epg-nz/do_mhegepgsnoop.conf
+[ -f $CONFIG_FILE ] && . /etc/mythtv-epg-nz/do_mhegepgsnoop.conf
+
 # The sourceid value for your FreeviewHD source.
-SOURCEID=1
+SOURCEID=${SOURCEID:-1}
 
 # Adapter number of DVB-T card.
-ADAPTER=0
+ADAPTER=${ADAPTER:-0}
 
 # DVB-T multiplex frequency (kHz)
-DVB_T_FREQ=610000
+DVB_T_FREQ=${DVB_T_FREQ:-610000}
 
 # Number of times to try mhegepgsnoop.py if it fails.
-TRIES=5
+TRIES=${TRIES:-5}
 
 # Amount of time to sleep between tries.
-SLEEP_TIME=5m
+SLEEP_TIME=${SLEEP_TIME:-'5m'}
 
 # Output file to store the xmltv EPG data.
 TEMP_FILE=/tmp/xmltv.xml
-OUTPUT_FILE=/home/mythtv/.mythtv/freeview.xml
+OUTPUT_FILE=${OUTPUT_FILE:-'/home/mythtv/.mythtv/freeview.xml'}
 
 # Channel map file.
 #MAP_FILE=/home/mythtv/.mythtv/mhegepgsnoop_channel_map.txt
diff --git a/etc/do_mhegepgsnoop.conf b/etc/do_mhegepgsnoop.conf
new file mode 100644
index 0000000..4efdf93
--- /dev/null
+++ b/etc/do_mhegepgsnoop.conf
@@ -0,0 +1,20 @@
+# The sourceid value for your FreeviewHD source. To identify, run:
+#
+# mysql -e "select sourceid,name,xmltvgrabber,useeit from videosource order by sourceid" mythconverg
+#
+SOURCEID=1
+
+# Adapter number of DVB-T card. To idenfify, run:
+#
+# mysql -e "select cardid,parentid,videodevice,cardtype,inputname,sourceid,displayname,schedorder,livetvorder from capturecard order by videodevice,cardid" mythconverg
+# 
+ADAPTER=0
+
+# DVB-T multiplex frequency (kHz)
+DVB_T_FREQ=610000
+
+# Number of times to try mhegepgsnoop.py if it fails.
+TRIES=5
+
+# Amount of time to sleep between tries.
+SLEEP_TIME=5m
-- 
2.30.2