mc2xml (media center TV Listings to XMLTV.xml)
bookmark: http://mc2xml.tk
mc2xml is a small and fast standalone command line program for Windows/Linux/OSX that downloads media center, titantv, or schedules direct tv listings and outputs an XMLTV formatted (xmltv.dtd) .xml file.

mc2xml options (case sensitive):

  •   -a               append " *" to new programs
  •   -A               append " *" to live programs
  •   -b               append " *" to not new programs
  •   -F               output channel "name" first (rather than "number name")
  •   -L               include <live /> tag (not part of xmltv.dtd)
  •   -u               output date/time in UTC (default = localtime)
  •   -U               output UTF-8 (default = "ISO-8859-1")
  •   -f               force re-download (use with caution)
  •   -d <#>           set listings duration (in hours)
  •   -s <[+/-]#>      set listings relative start position (in hours)
  •   -c <code>        set country code
  •   -g <code>        set postal/zip code
  •   -w <seconds>     wait for <seconds> and exit
  •   -t               use titantv service
  •   -y <id>          set 30 char id for titantv service
  •   -T <user>:<pass> use schedules direct service
  •   -i <#>           add <#> to all channel numbers
  •   -I <xmltv file>  include <xmltv file> in output
  •   -R <filename>    set ren filename (default = "mc2xml.ren")
  •   -D <filename>    set dat filename (default = "mc2xml.dat")
  •   -C <filename>    set channel file (default = "mc2xml.chl")
  •   -o <filename>    set output file  (default = "xmltv.xml")

mc2xml quickstart: (see also: FAQ: nextpvr, mythtv, mediaportal, ...)

  • Windows:

    1. Run "mc2xml", it has a simple graphical user interface
    2. Input postal code and country code and press OK
    3. Select lineup number from the returned list and an xmltv.xml file will be produced

  • Other OSs and command line usage:

    1. Run mc2xml with both the -c and -g parameters to set your location

      • -t is optional, and only works for US zipcodes
      • -T is optional, and requires an account user:pass (-c & -g are not needed)
      • -U is required for languages that contain non ISO-8859-1 characters

    2. Select lineup number from the returned list and an xmltv.xml file will be produced

  • mc2xml setup examples:

    • US: mc2xml -c us -g 20006
    • US: mc2xml -c us -g 20006 -t -y <id>
    • CA: mc2xml -c ca -g M1N2K3


    • AT: mc2xml -c at -g 1000
    • BE: mc2xml -c be -g 1000
    • BR: mc2xml -c br -g 20010-020
    • CH: mc2xml -c ch -g 1000
    • CZ: mc2xml -c cz -g "100 10"
    • DE: mc2xml -c de -g 10000
    • DK: mc2xml -c dk -g 1000
    • ES: mc2xml -c es -g 28000
    • FI: mc2xml -c fi -g 10000
    • FR: mc2xml -c fr -g 10000
    • IE: mc2xml -c ie -g 0
    • IL: mc2xml -c il -g 10000 -U
    • IN: mc2xml -c in -g 110000
    • IT: mc2xml -c it -g 00100
    • JP: mc2xml -c jp -g 1028000 -U
    • KR: mc2xml -c kr -g 100 -U
    • MX: mc2xml -c mx -g 22440
    • NL: mc2xml -c nl -g 1000
    • NO: mc2xml -c no -g 1000
    • PL: mc2xml -c pl -g 11-111
    • PT: mc2xml -c pt -g 1000
    • RU: mc2xml -c ru -g 101000 -U
    • SE: mc2xml -c se -g "100 10"
    • SK: mc2xml -c sk -g "100 10"
    • TR: mc2xml -c tr -g 01000 -U
    • TW: mc2xml -c tw -g 10000 -U
    • UK: mc2xml -c gb -g "SW1X 7LA"

 
Downloads (v1.2)

Windows (x86)
mc2xml.exe (892928 bytes)
MD5SUM: c6e2cf922bd441091baef0c5952ba660
Linux (x86)
mc2xml (1842952 bytes)
MD5SUM: eab9592d3524165f735feeeb07d67d90
OSX (x86 & PPC)
mc2xml (1442608 bytes)
MD5SUM: e0449f428db58aa815d7a50990e2504d


  • please do not mirror/redistribute files; integration within other package distributions prohibited without consent
  • avoid malicious code by always downloading from the homepage and checking the hash!
  • verify downloaded filesize to make sure your download is complete! if the program doesn't work ("not a valid application" or "program too big to fit" error) the download was interrupted and left incomplete!
  • some anti-virus programs (like norton) view compressed executables as potential threats: mc2xml is compressed for size

DonationWare: If this software is useful to you please donate!
This software is not crippled, but it is not freeware either. If you determine that it is useful to you please donate an appropriate amount. If it isn't useful, then you probably won't be using it! :)

Service information

  • Microsoft legacy service: Vista Media Center (and all previous versions of media center) offer Satellite, Cable and NTSC listings for many countries, but the data service might not fully support ATSC with subchannels for the North American market (yet?). Microsoft calls this the "legacy service".

  • TitanTV service: offers Satellite/Cable/NTSC & ATSC listings but only for the US market. The listings are good and the ATSC service seems complete, but the program details are not as robust as the media center service.

  • Schedules direct service: is a subscription based service (with 7 day trial) for Satellite/Cable/NTSC/ATSC TV listings in North America (and additional regions) from TMS/Zap2it.

  • Microsoft's (newest) service: If you have used Windows 7 or 8 you might have noticed more program information in the guide. It uses a completely new TV data service that seems to support everything that the microsoft legacy service supported, but adds full ATSC/subchannel support ("Digital Terrestrial"), plus listings include writer/producer credits, some season info, DVD cover & program images, as well as other miscellaneous program details. (note: Microsoft might have a North American focus?)

    Support for this new service in mc2xml is working, and now donators above the $20 level are welcome to request this version if they want to try it out (please specify operating system).

    (PBS offers mugs for donations; I don't have a mug for you but maybe this additional incentive will entice you to donate for the work that goes into mc2xml :) )

    Donators using a version pre v1.2: please send an email (from same address) for an update. Older versions may experience issues/old leftover timeouts. The current v1.2 is working.
    Incentive option #2 for users that would prefer a specialized linux binary for a system architecture other than x86, a cross compiled binary could be attempted. (example: mips32/lsb/uclibc) (Ensure the system has sufficient RAM!) (note: zap2xml is also still available for any systems that have perl)

General information

  • mc2xml will save your lineup selection to "mc2xml.dat" in the current directory. (It does not save -o or other input/output optional parameters other than -U/-u/-F/-A/-a)

  • Run "mc2xml" from the directory where "mc2xml.dat" is located whenever you want to output a new xml file. No command line parameters are required once the "mc2xml.dat" file has been created if you use the default input/output filenames (mc2xml.chl, xmltv.xml, etc).

  • To save bandwidth, the "mc2xml.dat" file also saves the version number of the listings when using one of the media center services. If you run mc2xml again and the listings have not been updated on the server, they will not be downloaded again ("No new data available").

    If you need to temporarily force a redownload the -f option can be used, (not necessary on the titantv or schedules direct services), but since this can overburden the servers it isn't recommended.

    It appears that media center server listings are only updated once a day at most, sometimes less frequently (and never on sunday's).

  • If you want to limit which channels are output in your xml file you can create a "mc2xml.chl" text file (in the same directory as mc2xml.dat). The channel inclusion and exclusion lists are initially empty so all channels will be included. Specifying channel numbers, channel number ranges, channel names, or channel ids on separate lines will create an inclusion list (perl style regular expressions are supported for names/ids). If the first character of a line is a "-" it will add to the exclusion list (which is the first list consulted in the case of overlap). If you only want to select channels to exclude, only use lines that start with "-" and leave the inclusion list empty.

     mc2xml.chl 
    5
    9-15
    17-21.2
    HBO
    BBC2 London
    # escape first character of name if a digit
    -[3]DTV
    -LOOR
    -PPV(\d+)
    I20.515292.microsoft.com
    # regex example
    I51.*tmsdatadirect.com
    I54.3.3945.titantv.com

  • If you want to rename some channel numbers or names you can create a "mc2xml.ren" text file (in the same directory as mc2xml.dat) listing the colon separated from:to channel numbers or names on separate lines:

    (the "from" can also be a channel id, to distinguish duplicate channel numbers or names)

     mc2xml.ren 
    605:2
    BBC1:BBC News
    I20.515292.microsoft.com:55

F.A.Q.

  • How would I use mc2xml with NextPVR?

    Note: This example assumes mc2xml.exe was downloaded to the C:\ folder and installs to the C:\EPG\ folder. Any folder name can be used but the contents of UpdateEPG.bat must point to the chosen folder name.

    1. Create a folder for the EPG data and put the mc2xml.exe binary in that folder (use a GUI file manager, Windows Explorer or the command line) (make sure folder is not read-only)

       command line example 
      md "C:\EPG"
      copy "C:\mc2xml.exe" "C:\EPG\"

    2. Optionally create an mc2xml.chl file listing the channels you want included in your EPG (see above for file format) (make sure that notepad doesn't append a ".txt" extension to this filename)

      If you do not specify which channels to grab all available channels and programme data for them will be downloaded resulting in a much larger xmltv.xml file size.


       command line example 
      notepad "C:\EPG\mc2xml.chl"

    3. Create a file called UpdateEPG.bat in the scripts folder of the NextPVR data directory and edit it with a text editor (notepad). Add any optional command line parameters to mc2xml that you might want. (make sure that notepad doesn't append a ".txt" extension to this filename)

       Location on Windows XP, Server 2003 
      C:\Documents and Settings\All Users\Application Data\NPVR\Scripts\UpdateEPG.bat

       Location on Windows 7, Vista, Server 2008 
      C:\Users\Public\NPVR\Scripts\UpdateEPG.bat

       UpdateEPG.bat 
      C:
      cd "C:\EPG"
      mc2xml

    4. Navigate to this UpdateEPG.bat file and run it (double click on UpdateEPG.bat) and mc2xml will ask you to input your Postal/Zip code (ie: "10000"), Country Code (ie: "us"), and will allow you to toggle any options (check "-a" and/or "-A" if you want *'s in your listings to indicate new programs).

      It will then ask you to select a lineup number. mc2xml will save this selection to mc2xml.dat and create an xmltv.xml file in this folder. (If you select the wrong lineup delete mc2xml.dat and try again)

    5. Configure NextPVR according to the type of capture device(s) on your system:
      1. For Analog devices:
        1. Select the analog device in the "Devices" section of the NextPVR "Settings" screen.
        2. Select "Device Setup" and use the "Import" option and browse to the location of the newly created xmltv.xml file.
        3. All available channels will be loaded. If you have not specified only the channels you wish to use in the mc2xml.chl file use the "Delete" option to remove channels you do not wish to view.
        4. "OK" all settings.
        5. Select the "UpdateEPG" button in the "Channels" section of the "Settings" screen which will populate the EPG with programme data.
      2. For Digital devices:
        1. Make sure to have run a channel scan on each device you wish to map the XML EPG data to in the "Devices" section of the NextPVR "Settings" screen and choose "Channels".
        2. Select a channel for which you wish to use the XML EPG source. From the drop down list select XMLTV and browse to locate the newly created xmltv.xml file.
        3. If NextPVR does not automatically match the channel name to the name in the XMLTV file use the dropdown list to choose the channel.
        4. "OK" this setting.
        5. If mapping multiple channels to your xmltv.xml file choose the "Bulk Map" option to easily edit the rest of the channels.
        6. Once finished editing use the "UpdateEPG" button to populate the EPG with programme data.
      3. For Analog and Digital devices on the same system use a combination of the above.

    6. Set the "EPG Update Hour" in the "Misc" section of the "Settings" screen and NextPVR will automatically run UpdateEPG.bat at the set time before it imports the programme data from the xmltv.xml file and updates the EPG.

  • How would I use mc2xml with GBPVR?

    1. Create a folder for the EPG data and put the mc2xml.exe binary in that folder (use a GUI file manager or command line)
    2. Optionally create an "mc2xml.chl" file listing the channels you want included in your EPG (see above for file format) (make sure that notepad doesn't append a ".txt" extension to this filename)

      • md "C:\Program Files\Devnz\GBPVR\EPG"
      • copy "C:\mc2xml.exe" "C:\Program Files\Devnz\GBPVR\EPG\"
      • notepad "C:\Program Files\Devnz\GBPVR\EPG\mc2xml.chl"

    3. Create a file called "UpdateEPG.bat" in the GBPVR folder and edit it with a text editor (notepad). Add any optional command line parameters to mc2xml that you might want. (make sure that notepad doesn't append a ".txt" extension to this filename)

       C:\Program Files\Devnz\GBPVR\UpdateEPG.bat 
      C:
      cd "C:\Program Files\Devnz\GBPVR\EPG"
      mc2xml

    4. Run this .bat file (double click on UpdateEPG.bat) and mc2xml will ask you to input your Postal/Zip code (ie: "10000"), Country Code (ie: "us"), and will allow you to toggle any options (check "-a" and/or "-A" if you want *'s in your listings to indicate new programs).

      It will then ask you to select a lineup number. mc2xml will save this selection to mc2xml.dat and create an xmltv.xml file in this folder. (If you selected the wrong lineup delete mc2xml.dat and try again)
    5. Run GBPVR Config and select the "Capture Source" tab and "Edit" your source
    6. Set the "EPG Source" to "XMLTV Plugin", and press the "Settings" button
    7. Select the "Browse" button and choose the newly created "xmltv.xml" file from the "C:\Program Files\Devnz\GBPVR\EPG" directory and press "OK"
    8. You can now press the "Update EPG" button and set the "Auto Update EPG" time. GBPVR will automatically run "UpdateEPG.bat" every time it imports the selected xmltv.xml file to update the EPG.


  • How would I use mc2xml with MediaPortal? *

    1. Create a folder for the EPG data (example: c:\mc2xml) and put the mc2xml.exe binary and a copy of xmltv.dtd in that folder (use a GUI file manager or command line)
    2. Optionally create an "mc2xml.chl" file listing the channels you want included in your EPG (see above for file format) (make sure that notepad doesn't append a ".txt" extension to this filename)
    3. MediaPortal wants the produced .xml file to be called "tvguide.xml", so you must open a DOS box, change to the EPG data directory and specify the output filename on the mc2xml command line.

      On the first run of mc2xml on Windows it will ask you to input your Postal/Zip code (ie: "10000"), Country Code (ie: "us"). If not using windows, you must specify this info on the command line.

      mc2xml will then ask you to select a lineup number. mc2xml will save this selection to mc2xml.dat and create a tvguide.xml file in this folder. (Delete mc2xml.dat if you selected the wrong lineup, and try again)

      • md "C:\mc2xml"
      • cd "C:\mc2xml"
      • copy "C:\downloads\mc2xml.exe" "C:\mc2xml"
      • copy "C:\downloads\xmltv.dtd" "C:\mc2xml"
      • notepad "C:\mc2xml\mc2xml.chl"
      • mc2xml -c us -g 10000 -o tvguide.xml

    4. Start MediaPortal's "TVserver configuration"
    5. Go to plugin "XmlTv" (make sure XmlTv plugin box is checked) and select the folder with the newly generated tvguide.xml (example: c:\mc2xml)
    6. Go to Tab "Mappings"
    7. Select your "Group"
    8. Press "Load/Refresh"
    9. The list box will now show your "channels" with drop down boxes to select the descriptions from the tvguide.xml file
    10. After selecting descriptions, press "Save"
    11. Verify the selections by pressing "Load/Refresh" again (all boxes should now be white)
    12. Go back to the "Settings" tab and press "Import" (you should see your channels/programs after importing (takes a few seconds))
    13. Close "TVserver configuration"
    14. Optionally schedule a daily task to keep the tvguide.xml file up-to-date:

      • Start->Control Panel->Scheduled Tasks->Add Scheduled Task (Press Next)
      • Browse and Select C:\mc2xml\mc2xml.exe
      • Select daily -> Next
      • Set desired time -> Next
      • Set computer username/password -> Next
      • Check "Open Advanced Properties when I click finish", and click Finish, and set these options (modify paths if necessary):

        • Run: c:\mc2xml\mc2xml.exe -o "c:\mc2xml\tvguide.xml"
        • Start in: C:\mc2xml

      • Press OK

  • Does mc2xml work with BeyondTV?

    • The xmltv importer for this software may require that you put a xmltv.dtd file in the same folder as the mc2xml created xmltv.xml file.

  • Does mc2xml work with SageTV?

    • The xmltv importer for this software may require that you put a xmltv.dtd file in the same folder as the mc2xml created xmltv.xml file.

  • How would I use mc2xml with Orb?

    • The Orb software company has a history of stealing and embedding/hiding mc2xml.exe (renamed to xmltvgrabber.exe) in their software bundle and claiming it as their own work. Avoid this company.

  • How do I crop the output of the schedules?

    • Use the -s and/or -d command line parameters (media center listings usually have 14 days worth of data by default). Make note of the "+" and "-" signs!

      mc2xml -s -5 -d 10
      output programs that start later than 5 hours ago, and include only the following 10 hours of programming
      mc2xml -s +5
      output programs that start later than 5 hours from now
      mc2xml -s 5
      output programs that start later than 5 hours after the downloaded listing's start time

  • Can I combine channels from multiple lineups and put them in one xml file?

    • If you are mindful of duplicate channels when creating your .chl files you can save your lineups to different .dat files and then chain them with the "-I xmlfile" insertion parameter

      • mc2xml -D NL.dat -C NL.chl -o NL.xml
      • mc2xml -D UK.dat -C UK.chl -I NL.xml -o UK_NL.xml
      • mc2xml -D DE.dat -C DE.chl -I UK_NL.xml -o DE_UK_NL.xml

  • How do I get ATSC listings for Canada using the MS services?

    • ATSC listings might not yet be available for Canadian postal codes using the MS services. Entering the nearest US zipcode (ie: a Buffalo zipcode for Toronto area channels) into mc2xml, along with using the channel renumbering (.ren file), selecting (.chl file) and multiple listing combination features described above can help build a Canadian ATSC listing. A list of ATSC channels and their frequencies for major Canadian cities can help.

  • How do I use the Schedules Direct service?

    • Use the "-T user:pass" command line parameter (user:pass is saved in mc2xml.dat). Default is 7 day download (change with -d <hours>).

  • How do I use the TitanTV service?

    • TitanTV is a source for US TV listings (and only US), but it does support ATSC and sub channels.
    • Add "-t" to the command line when initially selecting your lineup. Service selection is saved in mc2xml.dat
    • The service now requires your 30 character ID (not the same as a username on their web service) which can be specified on the command line by using the "-y " parameter (a default one has been included; if it expires you will receive a "-y" error and will need to specify your own (or find one on ye olde interweb)).
    • This service doesn't seem to compress its listings so the downloads can be large
    • By default a week of listings are downloaded, but this is configurable with the "-d" (duration in hours) parameter
    • This service occasionally seems slow or overloaded (or is running on a 286?) so if it is taking a few minutes to connect or download, it isn't stuck!, it really is just that slow
    • When the service is so busy that it is rejecting connections a status message is displayed and mc2xml will immediately exit with code 2 (to aid retry scripts)

  • Are there example retry scripts for the titantv service?

    • Example for windows:

     mc2xml-retry.bat 
    @ECHO OFF
    SET CNT=0
    SET MAX=15
    c:
    cd c:\mc2xml
    :START
      mc2xml -y <id>
      IF ERRORLEVEL 2 GOTO RETRY
      GOTO END
    :RETRY
      SET /A CNT += 1
      IF %CNT% == %MAX% GOTO END
      mc2xml -w 30
      GOTO START
    :END
    • Example for linux:

     mc2xml-retry.sh 
    #!/bin/sh
    CNT=0
    MAX=15
    cd ~/mc2xml
    while [ $CNT -lt $MAX ];
    do
      ./mc2xml -y <id>
      if [ $? -eq 2 ]
      then
        CNT=`expr $CNT + 1`
        ./mc2xml -w 30
      else
        break
      fi
    done

  • What can I do to customize the output of the listings?

    • It is easy to use sed (sed for windows) to alter the xml file. Here are some user contributed examples:

    • "Use sed to change the "-b" added asterisks into an [R] for "rerun" (or [N] for "new" when using "-a"). Since news programs usually are classified as reruns you can then change the [R] to NEWS for them. This solution is not perfect due to sed.exe control metacharacters commonly found in xml files, but it is close."

       command line 
      sed.exe -e "/<title lang=/ s/"*"/[R]/g" < "C:\mc2xml\xmltv.xml" > "C:\mc2xml\tvguidetemp.xml"
      sed.exe -e "/.*News.*"[R]"/ s/"[R]"/"NEWS"/g" < "C:\mc2xml\tvguidetemp.xml" > "C:\mc2xml\tvguide.xml"

    • "Add the team names from the sub-title to the title of NBA and College basketball games"
      • sed -f c:\mc2xml\sedscript.txt < c:\mc2xml\xmltv.xml > c:\mc2xml\newxmltv.xml

       sedscript.txt (cut&paste to read more easily)
      :a;N;$!ba;s/\(<programme[^<]*\)\(<t[^>]*>\)\(College Basketball[^<]*\)\(<[^<]*\)\(<sub-title[^>]*>\)\([^<]*\)[^<\/programme]*/\1\2\3: \6\4\5\6/g
      :a;N;$!ba;s/\(<programme[^<]*\)\(<t[^>]*>\)\(NBA Basketball[^<]*\)\(<[^<]*\)\(<sub-title[^>]*>\)\([^<]*\)[^<\/programme]*/\1\2\3: \6\4\5\6/g
      :a;N;$!ba;s/\(<programme[^<]*\)\(<t[^>]*>\)\(MLB Baseball[^<]*\)\(<[^<]*\)\(<sub-title[^>]*>\)\([^<]*\)[^<\/programme]*/\1\2\3: \6\4\5\6/g

    • "Remove all descriptions"

       command line 
      sed "/<desc/d" < xmltv.xml > xmltv-nodesc.xml

    • "Change ChannelID of channel 73 to a specific static number"

       command line 
      c:\programs\sed\bin\sed.exe "s/I73\.[^\.]*\.micro/I73\.999999999\.micro/g" c:\mc2xml\xmltv.xml > c:\mc2xml\xmltv-new.xml

    • "Remove the Channel# from ChannelIDs"

       command line 
      c:\programs\sed\bin\sed.exe "s/I[[:digit:]]\+\.\(.*microsoft.com\)/I\1/" c:\mc2xml\xmltv.xml > c:\mc2xml\xmltv-new.xml

  • Miscellaneous

    • Not all listing sources seem to have data available on the media center servers. If you select a source and receive a "No new data" status, try a different source.
    • Channel ids are currently a concatenation of number and id, since some listings have duplicate numbers while others have duplicate ids.
    • Libiconv is statically linked along with other libs in an attempt to keep the binary portable (but at the expense of file size).
    • The linux binary is statically compiled.

    • Definitions:

      • NTSC: analog terrestrial OTA (Over the air) aka Antenna (the US discontinued this service June 12 2009, Canada discontinued it on August 31, 2011.)
      • ATSC: digital terrestrial OTA (Over the air) aka Antenna: some channels are broadcast in High Definition but not all! Digital does not mean HD :)
      • ATSC sub channels: A digital channel has a certain amount of bandwidth (6MHz). Six 480i (standard definition) or two 1080i (high definition) streams can fit on one channel, so ATSC allows stations to divide a channel into subchannels. Example: 4.1, 4.2, 4.3.

    • Comments

    • mc2xml (at) gmail.com
© mc2xml