[mythtv-users] Detecting new channels

TimP mythtv at corky.co
Thu Jan 5 08:54:25 UTC 2023



On 2023-01-04 23:06, f-myth-users at media.mit.edu wrote:
> Using tv_grab_zz_sdjson_sqlite, is there some easy way, perhaps via a
> CLI option or enabling some logging, to notice if a new channel 
> (really,
> station or callsign) has appeared?  I imagine I could write something
> which periodically ran sdjson-sqlite-select (as the myth user! :) or
> tv_grab_zz_sdjson_sqlite --list-channels (ditto) and compared the 
> output
> to the last time, but is there some easier way?

I run this as part of a cron job that fetches the listings every day. 
Run it as the user mythtv and you'll get an email diff of the changes.

# Run the grabber and dump just the channels so this script can check 
for changes.
# Because the grabber caches programmes it doesn't double the amount of 
data fetched.
GRAB=tv_grab_zz_sdjson
export XML="$HOME/.xmltv/$GRAB.xml"
$GRAB --quiet --days 0 --output "$XML.new"
if [ ! -s "$XML.new" ]
then
     echo "Grabber failed to produce any output."
     exit 1
fi
# Reformat XML to have the channel names on one line (in reverse order 
for sorting).
awk --field-separator '[<>"]' \
   '/channel id/ {id=$3};
    /display-name/ {name=$3 "\t" name};
    /\/channel/ {print name "\t" id; name=""}' $XML.new \
     | expand --tabs=4,13,60 \
     | sort --numeric > $XML.new.txt
diff -uw "$XML.txt" "$XML.new.txt"
mv "$XML.new.txt" "$XML.txt"
rm "$XML.new"


More information about the mythtv-users mailing list