XMLTV CH

From MythTV Official Wiki
Revision as of 22:25, 23 March 2015 by Olla (talk | contribs) (added note on URL change)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Available Grabbers

tv_grab_ch_search

Note: search.ch went through a face-lift. The old layout is still available under tv.classic.search.ch - you will have to adapt the script accordingly.

This grabber may work on new versions of Mythtv but in version 0.25 some work is needed to get it functioning. I am running Mythbuntu 11.10. The version of tv_grab_ch_search that I am running is:

$ tv_grab_ch_search --version
XMLTV module version 0.5.59
This is tv_grab_ch_search.in version 1.14, 2010/10/26 08:43:10 
$

This also is the same version of tv_grab_ch_search that is installed on Ubuntu 12.04 from the normal repositories. Here is how I got it working with the above software versions. YMMV with other versions. ;)

1. Configuration

Run tv_grab_ch_search --configure to generate a configuration file with the channels you want to retrieve the information for when the grabber runs. You may have already done this in the MythTV backend setup. You can check if the default configuration file exists in ~/.xmltv/tv_grab_ch_search.conf the "~" is a reference to the current users home directory (i.e. /home/me/ or /home/username/) The back end normally runs as the user mythtv. This means that if you run this command as the user that runs the front end the file will be placed in that users directory and the mythtv user will not see it. So to run the command as the mythtv user use sudo like this and enter your user password when prompted.

sudo -i -u mythtv
tv_grab_ch_search --configure
exit

You can also run a GUI version of the configure which is a bit easier than answering yes or no so many times in a row as in the command above. With the GUI you can select the channels you want to grab info for.

sudo -i -u mythtv
tv_grab_ch_search --configure --gui
exit

2. Fix Encoding in version 0.25

In version 0.26(and presumably higher) of MythTV with Mythbuntu the xmltv_ch grabber in the repository uses the correct encoding. So this fix is no longer needed.Next we need to fix a encoding problem which you may or may not have. tv_grab_ch_search asks for the xmltv file to be in the ISO-8859-1 encoding and mythfilldatabase is defaulting to the UTF-8 encoding. This is why umlauts accented characters where not displaying properly after being imported into the database. The data imports into the database but umlauts and accented characters will not appear correctly. This maybe due to the fact that my system is running the locale us_EN instead of ch_DE or de_DE, however I do not think so as I see in the newer versions(v 1.17 2012/05/01 16:18:23+) of tv_grab_ch_search the following change has also been made. You may just want to download and replace tv_grab_ch_search instead of making the change manually. You can download it here on sourceforge.net. Mine is working so I did not try this.

Open /usr/bin/tv_grab_ch_search with your favorite text editor as the super user. I will show how to do this with nano. Enter your password when asked.

sudo nano /usr/bin/tv_grab_ch_search

Hit Ctrl-W and type encoding , this should bring you to the line you need to edit. Change it from:

$writer_args{'encoding'} = 'ISO-8859-1';

to:

$writer_args{'encoding'} = 'utf-8';

Then hit Ctrl-O to write out (which means save), and then Ctrl-x to exit nano.

3. Create mythfilldatabase_ch script

Next we need to write a short bash script to save our grabber data to a file and then have mythfilldatabase read it into the database. I found that this was not happening with the normal /usr/bin/mythfilldatabase commmand that was being run. I was always ending with a number error message and unexpected end of file messages. If someone else knows how to get it working that way please post it here.

Find input sourceid

Before we can create the script you need to know the sourceid you will need to use in the script(How to also found here). To do this you will need to query the database. You can use the mythtv database user and use the password that is setup in the MythTV Frontend: Setup > General > then on the Database Configuration screen 1/2 look in the Password field and use that password when prompted when running the commands below. If the user on this configuration page is not mythv then change that in the commands below. Open a terminal and run this:

mysql -u mythtv -p mythconverg

After entering your password at the mysql> prompt enter the following command:

select * from cardinput\g
You should see something like this:
+-------------+--------+----------+-----------+-----------------+----------------+---------------+----------+-----------+-------------+-------------+-------------+-----------+------------+-------------+
| cardinputid | cardid | sourceid | inputname | externalcommand | changer_device | changer_model | tunechan | startchan | displayname | dishnet_eit | recpriority | quicktune | schedorder | livetvorder |
+-------------+--------+----------+-----------+-----------------+----------------+---------------+----------+-----------+-------------+-------------+-------------+-----------+------------+-------------+
|           1 |      1 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 1         | DVB-T 0     |           0 |           0 |         0 |          1 |          10 |
|           2 |      2 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 1         | DVB-T 0     |           0 |           0 |         0 |          1 |          10 |
|           3 |      3 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 2         | DVB-T 1     |           0 |           0 |         0 |          3 |           8 |
|           4 |      4 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 2         | DVB-T 1     |           0 |           0 |         0 |          3 |           8 |
|           5 |      5 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 1         | DVB-T 0     |           0 |           0 |         0 |          1 |          10 |
|           6 |      6 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 1         | DVB-T 0     |           0 |           0 |         0 |          1 |          10 |
|           7 |      7 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 1         | DVB-T 0     |           0 |           0 |         0 |          1 |          10 |
|           8 |      8 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 2         | DVB-T 1     |           0 |           0 |         0 |          3 |           8 |
|           9 |      9 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 2         | DVB-T 1     |           0 |           0 |         0 |          3 |           8 |
|          10 |     10 |        3 | DVBInput  | NULL            | NULL           | NULL          | NULL     | 2         | DVB-T 1     |           0 |           0 |         0 |          3 |           8 |
+-------------+--------+----------+-----------+-----------------+----------------+---------------+----------+-----------+-------------+-------------+-------------+-----------+------------+-------------+
10 rows in set (0.00 sec)

mysql>

As you see the sourceid for all my tuners is 3 so that is what I will use in the script below change this to the sourceid for your card. (Note: I have a USB stick with two tuners that are multiplexed so that you can have 5 instances running on each tuner. That is why you see 10 listings and 2 displaynames.) You can then type:

exit

to leave the mysql prompt.

Setup mythfilldatabase_ch

Once again we need to run as the super user using sudo, so enter your password when asked. It is good for 5 minutes on Ubuntu with sudo. Create the file with:

sudo touch /usr/sbin/mythfilldatabase_ch

Then make it executable with:

sudo chmod +x /usr/sbin/mythfilldatabase_ch

Then edit it with nano with:

sudo nano /usr/sbin/mythfilldatabase_ch

Place the following lines in it:

#! /bin/bash
/usr/bin/tv_grab_ch_search --quiet > $HOME/.mythtv/tv.search.ch.xmltv 2>/dev/null
mythfilldatabase --file --sourceid 3 --xmlfile $HOME/.mythtv/tv.search.ch.xmltv

Then hit Ctrl-O to write out (which means save), and then Ctrl-x to exit nano.

4. Test mythfilldatabase_ch script

Next you can test the script to see if everything works properly before setting the MythTV backend up to use it instead of the mythfilldatabase script. If you prefer not to do this jump on to step 5. Otherwise in a terminal run:

sudo -i -u mythtv
mythfilldatabase_ch
You should then see something like this:
2013-04-09 08:18:09.148378 C  mythfilldatabase version: fixes/0.25 [v0.25.3-32-g79a24c9] www.mythtv.org
2013-04-09 08:18:09.148422 C  Qt version: compile: 4.7.4, runtime: 4.7.4
2013-04-09 08:18:09.148431 N  Enabled verbose msgs:  general
2013-04-09 08:18:09.148479 N  Setting Log Level to LOG_INFO
2013-04-09 08:18:09.148592 I  Added logging to the console
2013-04-09 08:18:09.148606 I  Added database logging to table logging
2013-04-09 08:18:09.148732 N  Setting up SIGHUP handler
2013-04-09 08:18:09.148830 I  Bypassing grabbers, reading directly from file
2013-04-09 08:18:09.148940 N  Using runtime prefix = /usr
2013-04-09 08:18:09.148965 N  Using configuration directory = /home/mythtv/.mythtv
2013-04-09 08:18:09.149221 I  Assumed character encoding: en_US.UTF-8
2013-04-09 08:18:09.150042 N  Empty LocalHostName.
2013-04-09 08:18:09.150058 I  Using localhost value of mythtv1
2013-04-09 08:18:09.171892 N  Setting QT default locale to EN_US
2013-04-09 08:18:09.171924 I  Current locale EN_US
2013-04-09 08:18:09.172010 N  Reading locale defaults from /usr/share/mythtv//locales/en_us.xml
2013-04-09 08:18:09.179849 I  Loading en_us translation for module mythfrontend
2013-04-09 08:18:09.183283 I  Current MythTV Schema Version (DBSchemaVer): 1299
2013-04-09 08:18:09.591656 I  IconData: Updating icons for sourceid: 3
2013-04-09 08:18:18.201819 I  Updated programs: 969 Unchanged programs: 318
2013-04-09 08:18:18.241387 I  Adjusting program database end times.
2013-04-09 08:18:18.256574 I      0 replacements made
2013-04-09 08:18:18.256588 I  Marking generic episodes.
2013-04-09 08:18:18.304858 I      Found 132
2013-04-09 08:18:18.304963 I  Extending non-unique programids with multiple parts.
2013-04-09 08:18:18.324467 I      Found 0
2013-04-09 08:18:18.324524 I  Marking repeats.
2013-04-09 08:18:18.360233 I      Found 0
2013-04-09 08:18:18.360252 I  Unmarking new episode rebroadcast repeats.
2013-04-09 08:18:18.362909 I      Found 0
2013-04-09 08:18:18.465308 I  Marking episode first showings.
2013-04-09 08:18:19.630749 I      Found 1286
2013-04-09 08:18:19.630765 I  Marking episode last showings.
2013-04-09 08:18:20.784773 I      Found 1286
2013-04-09 08:18:20.786839 I  
===============================================================
| Attempting to contact the master backend for rescheduling.  |
| If the master is not running, rescheduling will happen when |
| the master backend is restarted.                            |
===============================================================
2013-04-09 08:18:20.794031 I  MythCoreContext: Connecting to backend server: 192.168.1.50:6543 (try 1 of 1)
2013-04-09 08:18:20.796027 I  Using protocol version 72
2013-04-09 08:18:20.799078 N  mythfilldatabase run complete.
2013-04-09 08:18:20.827134 I  DataDirect: Deleting temporary files

Now type:

exit

to stop being the mythtv user. You can then check you program guide to see if you have correct data. Also, the system info display page will give the status of the program data and the last exit status. In the MythTV Frontend > Information Center > System Status > Listings Status

5. Change Guide Data Program in MythTV Backend Setup

Finally go into the MythTV Backend Setup program > General > then go to the last screen titled "Program Schedule Download Options" and change the field Guide Data Program from the default:

/usr/bin/mythfilldatabase

to

/usr/sbin/mythfilldatabase_ch

You can then exit the MythTV Backend setup program. If you use MythWelcome you can hit M to bring up the menu and run the mythfilldatabase command to manually run and test.