I have a number of IPTV networks with approx 10,000 channels. When a new channel tag is created (or channel group), it appears in tvheadend with a default "sort index" of 0 (zero).
For some reason, this impacts my KODI clients and removes all channel groups which are formed from the tags and leaves 10,000 channels in "All Channels" with all groups disappearing.
Can an option be added for the default starting "sort index" for new channels. I set my preferred channel sort index to like 10, 20, 30, 40 etc, so my favourite channels appear first. Then when a new channel is scanned, it appears at the very top and often stops my channel grouping from working. I will also raise this on the KODI forum.
I have tried creating a script which monitors the channel tag folder and if any channel tag gets added with a sort index of 0, it changes it to a higher number (in this example 999). The script works but unfortunately, tvheadend does not re-read the file until the server is restarted, unliking saving the sort index via the GUI, at which point KODi recognises the channel tag change and resorts the channel groupings. As a compromise is there a way to force tvheadend to re-load the channel tags from the CLI?
For reference, the script I have created is shown below:
#!/bin/sh
type grep >/dev/null 2>&1 || { 2>&1 echo "Missing dependency: This script requires grep"; exit 1; }
type sed >/dev/null 2>&1 || { 2>&1 echo "Missing dependency: This script requires sed"; exit 1; }
LOGFILE="/tmp/bouquet.log"
FILE="$1"
INDEX="0"
REPLACE="999"
SEARCH="\"index\"\: $INDEX"
COMMENT="Updated by iNotify"
COMMENT=$(echo $COMMENT $(date)|sed -r 's/\ /_/g')
case "$FILE" in
*~ | *.swp | *.swpx )
# echo"Ignore temp / swap file $FILE"
;;
*)
echo "$(date): Starting to process '$1'" >> $LOGFILE
echo "Searching for: $SEARCH in '$FILE'" >> $LOGFILE
cd /tmp
FOUND=$(grep "$SEARCH" $FILE)
if [ "$FOUND" ]; then
echo "Replacing Index: '$INDEX' with '$REPLACE' in '$FILE'" >> $LOGFILE
sed -E -i 's/"index": 0.*$/"index": '$REPLACE',/g;s/"comment": .*$/"comment": "'$COMMENT'"/g' $FILE
fi
echo "$(date): Completed processing '$1'" >> $LOGFILE
;;
esac
exit 0