[mythtvnz] Getting the current Freeview icons

Stephen Worthington stephen_agent at jsw.gen.nz
Fri Apr 15 13:41:08 BST 2022


The FreeviewHD EPG downloadable from here:

https://nzxmltv.github.io/xmltv/guide.xml

is created by scraping the freeviewnz.tv site's guide pages here:

https://freeviewnz.tv/tvguide/whats-on/

and I noticed that it also scrapes the icon URLs for the channels.
Since my channel icons are well out of date, I wanted to update them
to the same ones used by freeviewnz.tv.  So I wrote some Python to
parse the guide.xml file and extract the data I wanted:

http://www.jsw.gen.nz/mythtv/get-freeview-icons.py

To use this, do this:

cd /tmp
wget http://www.jsw.gen.nz/mythtv/get-freeview-icons.py
chmod +x get-freeview-icons.py
wget https://nzxmltv.github.io/xmltv/guide.xml
./get-freeview-icons.py guide.xml
chmod +x download-icons.sh

This will read the guide.xml file and create these two files from it:

download-icons.sh
freeview-icons.sql

The download-icons.sh file is a script containing wget commands to
download the icons.  To use it, do this:

cd /home/mythtv/.mythtv/channels
/tmp/download-icons.sh
chown mythtv:mythtv *
chmod u=rw,g=rw,o=r *

Then you need to update your channel table to use the new icons.  You
can do this manually, but it would be very tedious.  So that is what
the freeview-icons.sql file is for - it contains the SQL to create a
new freeview-icons table in your database that contains the data
needed to use an update command to change all the icons automatically.

To use it, first backup your channel table in case there are any
problems:

sudo su
cd /tmp
mysqldump mythconverg channel >channel.sql
exit

Should you need to restore the old channel table, you need to first
shut down mythbackend and then do these commands:

sudo su
cd /tmp
mysql mythconverg
drop table channel;
source channel.sql
quit
exit

Now create the freeview_icons table:

sudo su
mysql mythconverg <freeview-icons.sql

Then you can look at the freeview_icons table to see if you think it
is ok:

select * from freeview_icons;

If that is good, you can then do the icon updates.  First display the
current icons:

select channum,callsign,icon from channel where sourceid=1 order by
channum+0;

You will need to change the "sourceid=1" in this and subsequent SQL
commands to the correct sourceid number for your database.

Now do the update:

update channel c set icon=(select icon from freeview_icons f where
c.channum=f.channum) where sourceid=1 and (select count(*) from
freeview_icons f where c.channum=f.channum)!=0;

Check the icons by displaying them again:

select channum,callsign,icon from channel where sourceid=1 order by
channum+0;

Then tidy up and exit:

drop table freeview_icons;
quit
exit

Now check the icons that show in mythfrontend in the Guide.  If you
are unhappy with the result restore your channel table as above.



More information about the mythtvnz mailing list