[mythtv-users] XMLTV and mythfilldatabase

Simon Hobson linux at thehobsons.co.uk
Thu Apr 16 18:25:25 UTC 2020


DaveD <mythtv at guiplot.com> wrote:

> I have two lineups; OTA and Comcast cable.  The OTA is no big deal, but the Comcast lineup sucks.  It has almost 600 channels, many of which are wrong (don't come in at all or channels we DO get aren't listed), but for the most part, the ones we watch are ok.  The problem lies in that fact that we had to go through all 500+ channels and manually disable the On-Demand, and premium channels and low def channels and FM radio channels, etc, etc. The way we did that was suggested in the Wiki where you take the SD.xml file with the channel!<ID> (ones you don't want) vs channel=<ID> (ones you do want) and edit that with a text editor (similar procedure for the sqlite DB) changing the "=" to a "!" on ones you don't want and vise verse on one you do want.
> 
> That SD.xml file is used when you run mythfilldatabase to determine which channels it gets listing data for.  Unfortunately, it still creates all the channels from the lineup in the mythconverg channel table, it just doesn't pull any data for the "deselected" channels.  Since the channels table has a default "visible" value of 1, I ended up with all these "No Data" channels in my listings.  YUCK!
> 
> What I wound up doing was grep for all the "channel!" in the .xml file and output that to a file which I edited into an SQL query to set visible=0 where xmltvid=xxxx and ORed the hundreds of channels I didn't want.  I ended up with two files; one to set visible=1 on the channels with "=" and one to set visible=0 on the channels with "!".  All the useless channels are still there, happily created by mithfilldatabase, they just have no data.  After running my queries, at least the unused ones don't show up in the listings (except where the lineup has errors).
> 
> Don't know if any of this helps, but it's what I've done and figured I'd share FWIW.

have a look at https://www.mythtv.org/wiki/Database_editing_script
It takes some setting up as you need to work through your channels working out the IDs for the channels you want to see, but once setup you can reset your channels quickly every time you rescan.

Then, what I do is dynamically build the xmltv config file by querying the database for a list of channel IDs where visible=1. Doing it this way means only one place to maintain things - less work and automatically in-sync.


#!/bin/bash

base="/var/lib/mythtv/.xmltv"
conf="${base}/tv_grab_sd_json.conf"
xmlfile="${base}/listings.xml"
xmlfile2="${base}/sd.xml"

rm ${conf} ${xmlfile} ${xmlfile2} 2>/dev/null

cp ${conf}.base ${conf}

mysql --host=localhost --user=mythtv --database=mythconverg --password='*****' \
  -e "select distinct(xmltvid) from channel where visible=1 and useonairguide=0 order by xmltvid ;" |
  grep '[0-9][0-9][0-9][0-9][0-9]' |
  sed -e 's/^/channel=/' >> ${conf}

/usr/bin/tv_grab_zz_sdjson --config-file ${conf}  --output ${xmlfile}
/usr/bin/tv_grep --output ${xmlfile2} --not --title 'To Be Announced' ${xmlfile}

mythfilldatabase --only-update-guide --sourceid 1 --file --xmlfile ${xmlfile2} 2>&1 | grep -v 'Ignoring unknown timestamp format'


As a quick hack, I get a list of channels and their IDs for my lineup with a short script. That gives me a relatively small file containing a list of channels that I can search to match up the names as found during the scan with the names as used by Schedules Direct.

#!/bin/bash
# Get full xml listing and extract channel-ids & names

base="/var/lib/mythtv/.xmltv"
conf="${base}/tv_grab_sd_json.conf"
chan_file="${base}/channels"

rm ${conf}.full ${chan_file}.txt ${chan_file}.xml 2>/dev/null

sed -e 's/channels/lineup/' < ${conf}.base > ${conf}.full

tv_grab_zz_sdjson --config-file ${conf}.full --days 0 --output ${chan_file}.xml
grep 'channel id
display-name' < ${chan_file}.xml > ${chan_file}.txt


Simon



More information about the mythtv-users mailing list