Home
Blogs
Forums
Files


Welcome to The Green Button          Sign in | Join | Help

EPG Guide's Schema

Last post 06-27-2008, 1:03 AM by pclare. 3 replies.
Sort Posts: Previous Next
  •  06-25-2008, 6:47 AM 270067

    EPG Guide's Schema

    Hi, I am a student working on Vista MCE and i'm trying to get the Electronic Program Guide's informations.

    I tried to use ehiProxy.dll and ehepg.dll in order to access the guide throw the interface they provide. But I think i'm missing something because it doesn't work. Or maybe the application have to be a MCE plugin ?

    I decided to access directly to the database (stocked in \Program Data\Microsoft\eHome\EPG\ ) but it's kind of a mess in there.. It seems there is a lot of data redundancy. So if someone has already made a nice schema of the database it will save me some time..

    And for the last question: do anyone know what is the .xml file which have the same name than the database .sdf file ?

    Thank you, and sorry for my english. :s


  •  06-25-2008, 10:47 AM 270145 in reply to 270067

    Re: EPG Guide's Schema

    Ask the Vista forum. This is MCE2005.
  •  06-27-2008, 12:51 AM 270499 in reply to 270145

    Re: EPG Guide's Schema

    MitchSchaft:
    Ask the Vista forum. This is MCE2005.

    The Guide database is essentially the same in Vista as it is in MCE2005.  And since there isn't a "Hacks & Mods" section for Vista this is as good a forum as any to ask the question.  Actually, I've yet to find a forum anywhere (on TGB or elsewhere) that gives good coverage to this sort of system level development with MCE/VMC.  Yes, there are plenty of discussion forums on Media Center application development but they all focus on using the supplied Media Center SDK and not on doing things like accessing the Guide data or other system level stuff.

    Anyway, back to the original question....

    You are on the right track trying ehepg.dll/ehepgdat.dll/ehiProxy.dll.  It is possible to access the Guide using these assemblies.  The app doesn't need to be an MCE plugin, just a .NET application.

    Here's a fragment of code (that can be used in a console app) that will access the Guide and print out the end time of valid data.  You can access other properties in a similar way.

    Microsoft.Ehome.Epg.Ehepgdat ehepgdat = new Microsoft.Ehome.Epg.Ehepgdat();
    Microsoft.Ehome.Epg.Guide currentEpgGuide = (Microsoft.Ehome.Epg.Guide) Microsoft.Ehome.Epg.Guide.CurrentEPG;

    Console.WriteLine( "End time: " + currentEpgGuide.EndTime.ToShortDateString() + " " + currentEpgGuide.EndTime.ToLongTimeString() );

    As you have probably found, the Guide is stored in a SQLLite database.  Assuming that you know the name of the current database file (which can be found from the "currentEpg" setting in the registry) then querying this database is easy.  Here's an example that will access the services (i.e. channels) data and output it in the form of CSV data (which could then be read into Excel, for example).

    // set up variable currentEpgFile with full path to Guide database file

    SqlLiteConnection sqlConnection = new SqlLiteConnection();
    sqlConnection.Init( currentEpgFile, true );
    sqlConnection.Open();

    SqlLiteCommand sqlCommand = (SqlLiteCommand) sqlConnection.CreateCommand();
    sqlCommand.CommandText = "select * from services";
    sqlCommand.CommandType = CommandType.Text;
    SqlLiteDataAdapter sqlAdapter = new SqlLiteDataAdapter();
    sqlAdapter.SelectCommand = sqlCommand;

    DataSet ds = new DataSet();
    sqlAdapter.Fill( ds );
    sqlConnection.Close();

    for ( int i = 0; i < ds.Tables[ 0 ].Columns.Count; ++i )
    {
        if ( i != 0 )
        {
            Console.Write( ", " );
        }

        Console.Write( ds.Tables[ 0 ].Columns[ i ].ColumnName );
    }
    Console.WriteLine();

    foreach ( DataRow row in ds.Tables[ 0 ].Rows )
    {
        for ( int i = 0; i < ds.Tables[ 0 ].Columns.Count; ++i )
        {
            if ( i != 0 )
            {
                Console.Write( ", " );
            }

            if ( row[ i ].GetType() == typeof( string ) )
            {
                Console.Write( "\"" + row[ i ] + "\"" );
            }
            else
            {
                Console.Write( row[ i ].ToString() );
            }
        }
        Console.WriteLine();
    }

    Hope that helps,

    Pete

     


  •  06-27-2008, 1:03 AM 270501 in reply to 270067

    Re: EPG Guide's Schema

    telchar:

    And for the last question: do anyone know what is the .xml file which have the same name than the database .sdf file ?

    The .xml extensions is misleading since if you examine the file you can easily see that it does not contain XML text.  This file does actually contain XML but it's been encrypted (which is why the contents just looks like raw binary rather than text).  The file (usually) originates from one of Microsoft's commercial Guide servers and it contains the programme scheduling information used to populate the Guide (i.e. programme names, descriptions, start times, end times, etc.).

    Pete

View as RSS news feed in XML
About TGB | Advertise | Link To Us | Donate | Terms Of Use | Privacy Policy
© 2003-2007 The Green Button, Inc. - All Rights Reserved