XMLTV grabber for Belgium (1 Viewer)




Here is a small howto for getting an XMLTV grabber working for Belgium. Follow this step by step and you should get there. For me it is running for version 0.3.2.

Have fun with it,


PS: If you don't want to do all of this, just wait, a grabber for Belgium will soon be added to the default set of XMLTV grabbers (from what I have heard ;-)).

1. Install Python
2. Go to http://sourceforge.net/projects/pytvgrab/ and download
-pytvgrab-be_tvb (dutch listings) or pytvgrab-be_tlm (french listings)
3. extract both packages
4. from the directory pytvgrab-lib run "setup.py install"
5. in the directory pytvgrab-be_tvb rename the file tv_grab_be_tvb to tv_grab_be_tvb.py
6. copy the file to the xmltv directory of Media Portal
7. edit C:\Python23\Lib\site-packages\tvgrab\grab.py
config_file = '%s/.xmltv/%s.conf' % (os.environ['HOME'], os.path.basename(sys.argv[0]))
config_file = '%s/My Documents/xmltv/%s.conf' % (os.environ['USERPROFILE'], os.path.basename(sys.argv[0]))
8. run tv_grab_be_tvb.py twice, ignore the error message the first time.
9. choose the channels you want
10. edit tvguide.bat in the xmltv directory of mediaportal
tv_grab_nl.py --output=tvguidenew.xml
tv_grab_be_tvb.py -o tvguidenew.xml


Wonderfull ! That's exactly what I was looking for.

If I may had, if you install over a previous version, just make sure you delete the files in Python23\Lib\site-packages\tvgrab first,
because running setup.py install won't overwrite the old files of the tv grab libraries...


XMLTV grabbing for Belgium became easier


Just a small update on the status of the XMLTV grabbers for Belgium. The sourceforge project "python xmltv tv_grab" has been greatly improved and now also includes windows installers.

This update is a must have for all Belgian users.

After installing the latest versions you only have to update the tvguide.bat file to use the newly installed grabber. Here is the tvguide.bat file I currently use.

del tvguidenew.xml
del tvguideold.xml
Sleep 10
C:\Python23\Python C:\Python23\Scripts\tv_grab_be_tvb --output=tvguidenew.xml
if errorlevel 10 goto start

ren tvguide.xml tvguideold.xml
ren tvguidenew.xml tvguide.xml


Hi there,

First off, thanks for the guide. I would have been lost without it. I followed all the steps you suggested and I do get an tvguide.xml file (I can follow the download process in the dos prompt, everything seems to be fine). When I try to import the information from the guide by pushing f3 in the tvguide screen in mediaportal, I get an error about an invalid XML file. The same file works in GBPVR however. Does the process still work for the latest build If I try to open the .xml file in IE6 I also get an error. It can't find the DTD. Is this the cause?

Thanks again.


Retired Team Member
  • Premium Supporter
  • September 27, 2004
    Home Country
    Belgium Belgium
    Yes that is the cause. Please search the forum, there is a link somewhere where you can download the DTD file...


    This thread is a bit old, but I'm totaly lost with what to do!
    I guess there have been a lot of changes in versions...

    Thanks in advance!


    Portal Member
    April 1, 2005
    I'll try to explain all again as I did it yesterday (no guarantee that this is the best method, but it works for, using IceFreds explanation as a base, so all credits go to him really:

    - I use Windows XP Pro as OS.
    - <python> is the directory where python is installed (ie C:\Python24)
    - <mp> is the root directory where MediaPortal is installed

    - Download and install python.
    - Grab the lib (0.5.1) and be_tvb (dutch) or be_tlm installers (0.5.0) here and install them both.

    Since windows does not have an environment string called "HOME" by default which the scripts use to store the config, we'll edit the grab.py file so that it (the configfile) gets placed in a good location:
    - Edit <Python>\Lib\site-packages\tvgrab\grab.py
    - Find the line that says:
    fname = "%s.conf" % os.path.basename( sys.argv[ 0 ] )
    (it's in the __init__ function of the Grab_C class (line 429 here)
    - Replace it by:
    fname = '%s/%s.conf' % (os.environ['USERPROFILE'], os.path.basename(sys.argv[0]))
    (this places the config in your user-profile, usually C:\Documents and Settings\<username>\tv_grab_be_t??.conf)
    (I deviated from what IceFred stated because I personally don't want it in the "My Documents" folder for one, and secondly, not everybody has that folder, on a Dutch XP eg)
    - Save the file.

    Now we're gonna run it for the first time so it can create the configuration:
    (Note: the <-[ codes are ANSI codes for color, since that doesn't work in a default XP dos box, you'll have to ignore them)
    - Open a commandprompt and go to the folder <Python>\Scripts\
    - Type in:
    ..\Python tv_grab_be_tvb
    (for dutch) or
    ..\Python tv_grab_be_tlm
    (for french)
    - The script will show you the location for the configfile, if you are okay with it, just hit enter.
    - Next, it'll show you all detected channels, one by one. Pick the ones you need. (Remember: the more you answer yes to, the longer it'll take to update the listing, but that's your choice).
    - After the channel selection is done, the script starts to fetch all data, but I just Control+C it, since we don't need it yet.

    Next step in the line: create the batch file that will update the tv-listing xml.
    - Create a batch file in <mp>\xmltv (eg tvguide.bat)
    - The following is the contents for it:
    @echo off
    del tvguidenew.xml 2> NUL
    del tvguideold.xml 2> NUL
    sleep 10
    <Python>\Python <Python>\Scripts\tv_grab_be_tvb --output=tvguidenew.xml --quiet
    if errorlevel 10 goto start
    ren tvguide.xml tvguideold.xml 2> NUL
    ren tvguidenew.xml tvguide.xml 2> NUL
    ..\TVGuideScheduler.exe /file tvguide.xml
    -> Remember to change <Python> to the Python installation directory
    -> Sleep.exe is not a default part of the Windows distribution but can be downloaded here (place it in your windows directory or somehting).

    If you want to see the script running for the first time, just remove the --quiet at the end of the grab line and save the file. The script output's all fetched data on screen and afterwards writes the tvguidenew.xml file. (it can take a while, don't be impatient!). I prefer not having to follow all the text, hence the quiet option.

    If, after running the batch file, you have a tvguide.xml file in your <mp>\xmltv directory, all went well.

    Now we only have a few simple things left to do:
    - Open the MP Configuration
    - Below Television\Program Guide, make sure that the xmltv directory is correct, and, on the "Sheduler"-tab, you select the "TVGuide.xml file"

    Since the sheduler doesn't know about our own tvguide.bat file, we can't use the built in sheduler.
    Instead go Start\All Programs\Accessoires\System Tools\Sheduled Tasks and add a sheduled task there, your tvguide.bat
    You decide on the shedule. If you simply want it to run at boottime, add a shortcut to the Startup Folder, you decide.

    - Reordering the channel listing? In the config-program below Television/Channels. Just use Up and Down to get the order you want. Uncheck a channel to exclude it from the guide (it will still be fetched!).

    Hopefully that works for you belgian people, it does for me ;)

    edit: Added TVGuideScheduler call. This will update the TV Database since we arent using the MP built in schedule command (at least i'm not) ;)


    New Member
    January 28, 2005
    1 hour off

    the tv guide for belgium with python includes +1:00 and so mediaportal always is 1 hour of. If you use the time compensation in the configure console of media portal it sets the times ok but you have to do this every time you get the new guide. Is there a solution to set the time compensation when downloading the new guide as an command line option in the python tv guide refresh ?


    Portal Member
    April 1, 2005
    Yes you can.

    The tv_grab_be_t?? scripts have a timeshift option for this, just change the following line from the batch file:
    <Python>\Python <Python>\Scripts\tv_grab_be_tvb --output=tvguidenew.xml --quiet
    <Python>\Python <Python>\Scripts\tv_grab_be_tvb --output=tvguidenew.xml --quiet --toffset=-60

    That will set all hours in the XML back by 1 so that your hours are correct.
    Small note: don't forget to click "Remove all programs from TV Database" first to clear the already existing ones before downloading it again.


    New Member
    February 22, 2005
    As I'm more a unix/linux guy I use only unix commands from GNU unixutils.zip see http://unxutils.sourceforge.net
    I had some issues with not getting all gif's correct in the tvguide.
    Solution to this is:
    Just grab and then postprocess the file and correct the errors

    In to xmltv folder put following files

    sed.exe (stream editor (awk is even better))
    cp.exe (copy command)

    tvguide.bat (my unix/windows version)
    rem install first python2.4
    rem install then libraries pytvgrab-lib-0.5.1
    rem install at last tv_grab_be_tvb
    rem gets xmltv.dtd file from xmltv
    rem sed = extra edits after grab
    REM Grabs from www.teveblad.be
    rem c:
    rem cd "C:\Program Files\Team MediaPortal\MediaPortal\xmltv"
    REM Put here all files
    REM Get tvguide
    C:\Python24\python C:\Python24\Scripts\tv_grab_be_tvb -o tvguide_new.xml
    if errorlevel 10 goto start
    REM Copy old one
    cp tvguide.xml tvguide_prev.xml
    REM rename een.gif to TV1.gif and other gifs
    sed -f tvguide.sed tvguide_new.xml > tvguide.xml
    tvguide.sed (file with multiple edits)

    I use *.conf file with all channels as a default
    "s/aaa/bbb/g" = change string aaa to bbb global means till end off line (multiple occurences in one line)
    Special char "/" must be indicate with "\" (see nbc line)
    Also manipulations on the whole file is possible, like adding things to sertain lines with this "sed" command.
    In a dos box typing help you see 100 commands. In unix there are over 2000 commands to use " (sed is only one of them).

    Last four channels we don't have in belgium but its for completeness ;-)

    Users who are viewing this thread

    Top Bottom