EPG

EPG shows you what's on on TV see: https://en.wikipedia.org/wiki/Electronic_program_guide

Check that the time and timezone of your system is set correctly otherwise no matching EPG data can be found: date

The EPG data is usually put in a file /tmp/TV.xml. The format of the file is broadly accepted, however the path might makes some troubles. The //tmp directory gets wiped off when you boot the PC. This means you will have no EPG data when you boot. Usually you fetch EPG data for a couple of days, so even when the data is old it still contains todays TV program. It is also not the best option to always grab the data when booting. It takes a lot of time, might slow down the boot time and all TV application must wait until it is done before using EPG. Therefore just use an other path for TV.xml.

Two ways how it comes to your PC:

Nxtvepg

Analogue TV cards can receive EPG via the information in the VBI (Vertical Blanking Interval ) of the Video signal. The VBI is the historic time gap where the cathode ray tubes have moved their beam from lower right corner to upper left, during this time nothing is visible because the beam is blanked. However this VBI time slot is used to transmit all kinds of data as Teletext, EPG, Test lines, 16:9 4:3 mode information, copyright protection.

Figure 12.8. Nextview

NextView


To get a VBI based online TV guide emerge nxtvepg (set use flag zvbi). See http://nxtvepg.sourceforge.net/. A disadvantage is that it can update the info just when your TV card has tuned to the channel that you have in your nxtvepg setup. However when you do not watch TV or when you watch TV on this particular channel, nxtvepg acquires the EPG data.

An advantage is that it comes in a standardized format so it is much more stable than xmltv and usually much faster.

There is a possibility to start nxtvepg without user interface and export a xml file that is compatible to xmltv. Nxtvepg runs then as acquisition daemon server and produces a socket

An other instance of nxtvepg can then act as client (or browser) and can then dump /tmp/nxtvepg.0 to the /tmp/TV.xml file.

Once configured nxtvepg takes all its settings from ~/.nxtvepgrc. Since you want to start nxtvepg from an initscript copy the ~/.nxtvepgrc to an absolute directory e.g:

cp ~/.nxtvepgrc /usr/local/share/nxtvepgrc

so it can be used in a script. The command in the script would than look as:

/usr/bin/nxtvepg -rcfile /usr/local/share/nxtvepgrc -daemon

and could be part of an /etc/init.d/script to have a nxtvepg daemon running in background. /etc/init.d scripts have start and stop functions. To stop the following line could be used:

/usr/bin/nxtvepg -rcfile /usr/local/share/nxtvepgrc -daemonstop

However the two commands above just start and stop the daemon but do not create a /tmp/TV.xml file. After having given some time to the nxtvepg daemon to acquire EPG data the following command would convert the nxtvepg cached data into the /tmp/TV.xml file:

/usr/bin/nxtvepg -rcfile /usr/local/share/nxtvepgrc -dump xml -provider merged > /tmp/TV.xml 2> /dev/null

Note: The / character is used to split the command to two lines.

Here a Gentoo /etc/init.d/nxtvepg init script:

#!/sbin/runscript
depend() {
  need modules
}
start() {
# display to the user what you're doing
  ebegin "Starting nxTVview EPG daemon"
# Start the process as a daemon
  /usr/bin/nxtvepg -rcfile /usr/local/share/nxtvepgrc -daemon
  THRICE=2
  while test $THRICE -gt 0
  do
  /usr/local/sbin/nxtvepg2xmltv
   HEADER=`head -n 1 /tmp/TV.xml | grep "<?xml"`
  if [ -n "$HEADER" ]; then
    break
  fi
  THRICE=`expr $THRICE - 1`
  sleep 1
  done
# output success or failure
  eend $?
}
stop() {
# display a message to the user
  ebegin "Stopping nxTVview EPG daemon"
# stop the daemon
#killall nxtvepg
 /usr/bin/nxtvepg -rcfile /usr/local/share/nxtvepgrc -daemonstop
# output success or failure
  eend $?
}

The script above calls an other script /usr/local/sbin/nxtvepg2xmltv that actually dumps the /tmp/TV.xml file:

#!/bin/sh
/usr/bin/nxtvepg -rcfile /usr/local/share/nxtvepgrc -dump xml /
-provider merged > /tmp/TV.xml 2> /dev/null 

To log what is going on add the following line to the script above:

date >> /tmp/nxtvepg.log

Finally make sure both scripts have executable permission and add the init.d script to the default runlevel

rc-update add nxtvepg default

If problem occur with the scripts make sure /etc/init.d/nxtvepg start and /etc/init.d/nxtvepg stop run without problems. If /etc/init.d/nxtvepg stop does not find the daemon then also dump /tmp/TV.xml will fail. In this case try to create a new /usr/local/share/nxtvepgrc/.nxtvepgrc file.

Note

The solution with a nxtvepg daemon disables all the Teletext features of the other TV applications as Alevt and Kdetv. Therefore a solution with a cron job that may run once a day might be the better solution. When nxtvepg starts it produces the file /tmp/.vbi0.pid that holds the PID of its process, the command kill $(cat /tmp/.vbi0.pid) kills nxtvepg to get access to the teletext device /dev/vbi0.

XMLTV

http://wiki.xmltv.org/index.php/Main_Page/ is a standalone console program that gets the EPG from Internet. It serves as engine for other programs having a GUI. However, it uses grabbers that take the data from web pages and extract the EPG from HTML. Since web pages change frequently its format without notice, bad surprises can happen and the xmltv package will not getting a new version and release just because one of the many grabbers have changed. xmltv uses grabbers written in perl. But http://pytvgrab.sourceforge.net/ has grabbers written in Python.

Check about the xmltv specific useflags to select the EPG provider.

cat /usr/portage/profiles/use.local.desc |grep xmltv:

Or check https://www.gentoo.org/support/use-flags/

Add to /etc/portage/package.use

media-tv/xmltv ch

check first the useflags emerge xmltv -vp

and finally emerge xmltv

Now working as a user and no more root, to create a selection of TV stations for your area look under /usr/bin to get the right command:

tv_grab_ch_search --configure

and select the channels of your interest and not more. If you select more than it simply takes long until the updates finish. An other way is to select all and edit the file containing the list in ~/.xmlt you will have now a ~/home/.xmltv/tv_grab_ch_search.conf that contains the stations.

tv_grab_ch_search --days=1 > /tmp/TV.xml gets you the TV program but it takes a while! You also have to repetitively do it since days go by. So cron can help you out.

Create a script and make it executable

#!/bin/bash

tv_grab_ch_search --days=3 > /tmp/TV.xml

Run it to see if it works and if it creates a /tmp/TV.xml file, that can be observed using a XML editor. It requires the file ~/.xmltv/tv_grab_ch_search.conf

Xmltv has it dtd in /usr/share/xmltv/xmltv.dtd

Assuming you run vixie-cron tape crontab -e and add the following to have epg updated twice a day:

0 */12 * * * /home/lindegur/Urs/sw/bash/xmltv

Check if it is scheduled crontab -r

Frontends for XMLTV

mtvg

emerge mtvg is a simple handy application that does the job well. To setup click to preferences updates where your file is /tmp/TV.xml and if you use XMLTV the command to update it:

tv_grab_ch_search --days 7 --output /tmp/TV.xml

If you use an other method than XMLTV to create /tmp/TV.xml as NXTVEPG then leave the command field empty.

~/.kde/share/config/maxemumtvguiderc is where the configuration data goes.

/usr/share/doc/mtvg is where the documentation is.

In the mtvg options do not enable hide history, since this also hides the present and past.

ktvschedule

ktvschedule (works but is rather ugly)

mtvg and kscheduler stay alive and keep XMLTV up to date.

tvbrowser

tvbrowser a lot of masked packages have to be emerged. It is written in Java and has a nice gui.


Linurs startpage