[mythtv-users] UK EPG

Simon linux at thehobsons.co.uk
Tue Jan 2 20:28:43 UTC 2024

Andy Harvey <andy at harvs.net> wrote:

>> I've been using Schedules Direct in the UK for several years now. There have been a few temporary minor glitches (none recent), but it's mainly worked really well for me. I'm not sure what support MythTV provides for setup of UK Schedules Direct. Back when I started using it, the support was minimal and I ended up writing some scripts to heuristically match schedule channel names to transmission channel names and from that fill in what's needed in the database channel table. MythTV may well have improved in that respect since then. 
> Ditto to that. I've been using Schedules Direct for UK schedules for a few years too. The data is pretty good episode numbers, first broadcast date, etc are fairly reliable. When there have been problems they are fairly responsive to support requests, though I've only raised a few tickets in 7 years using them. It's only $35 per year - a lot less than the Radio Times.

+1, SD is well worth the fairly modest cost.

The lookahead time you get is “variable” - I did query them about it some time ago and was told that it all depends what their upstream gives them. For the “main” channels like BBC etc, there seems to be around 10 days, for some channels it goes out to about 17 days.

When I started I got a LOT of entries that were just "To Be Announced” so (with help from this list) I added a bit to my script to strip those out.

The biggest issue IMO is getting the channel to XML ID set. But this can be solved alongside managing channels in general by script - see https://www.mythtv.org/wiki/Database_editing_script (hmm, must remember to update that page sometime, it’s out of date as there’s no longer a mysql config file you can “dot in”).
Mine now looks like :
> #. /etc/mythtv/mysql.txt
> DBName=mythconverg
> DBUserName=mythtv
> DBPassword=********
> echo '
>  create temporary table t1 as select max(channum) as channum from channel group by callsign having count(*)>1;
>  delete from channel where channum in (select channum from t1);
>  drop temporary table t1;
>  update channel set useonairguide=0 ;
>  update channel set channum=channum+10000 where channum < 700 ;
>  update channel set visible=0 where not channum between 700 and 799 ;
>  update channel set visible=1,channum=1  ,xmltvid="24325"                    where callsign="BBC ONE N West” ;
> ...

With this, you still need to manage the mappings, but once set you can delete channels and rescan - then just run the script again to reset everything. Of course, every time you rescan you’ll find someone’s changed a channel ident, or channels have come/gone, or ... So you have to see what’s changed, update the script, then run it again. At some point I think there were channels appearing twice (during a reshuffle), hence the bit deleting some.

My grabber script is not pretty, but it works :
> #!/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
> #cd
> 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}
> #cat tvgrab >> ${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’

The base config file contains :
> channel-id-format=mythtv
> username=yourSDuseridhere
> password=yourSDpasswordhere
> mode=channels
> channels=GBR-1000040-DEFAULT

The script above appends a list of channel IDs - by fetching it from your channels table in the Myth DB you avoid any need to maintain the list in more than one place, and by fetching listings a list of channels you only fetch what you actually need.

For completeness, I also have a script that just grabs a list of channels into a text file so you can search for the channels you are missing XML IDs for :
> #!/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

Again, probably far from the neatest solution, but it works for me.

Hope this helps, Simon

More information about the mythtv-users mailing list