Windows Entertainment and Connected Home

How to organize, access and enjoy all of your media in and around your home

Accessing the MCE Guide Listing database in Windows 7

  • rated by 0 users
  • This post has 17 Replies |
  • 7 Followers
Page 1 of 2 (18 items) 12
  •  

    I am a .NET developer and have written a WPF application that provides useful features to improve the MCE experience in Vista Ultimate. One example is a utility that makes it very quick and easy to re-order the guide listing. I used ehepg.dll to access the .sdf database.

    I now want to convert this application to work for Windows 7 and do the same for mcepg2-0.db but am really struggling to find any information on the web how I can access mcepg2-0.db and manipulate the guide listing order as the .db file is password protected.

    Can anyone give me a pointer as to the best way to approach this problem or let me know where I can look to get me going?

    Thank you in advance.

  •  
    Tony, Your thread is pretty old now but have you seen this? http://social.msdn.microsoft.com/Forums/en/netfx64bit/thread/ea979075-f602-475d-b485-3a4f787dcb70
  •  

    Thank you very much for that link. Very interesting, although we still seem to be some way from what I am after (being able to manipulate the MCE database).

    I am still very interested in any further information on this topic.

    I'll get back with any info I discover.

  •  

     Hi,

    the msdn forum thread was posted from me.

    I don't think you can directly access the database, because it is password protected. You have to get the password.

    Accessing the EPG from code works in MC Addin only (for me).

    You have to get the store first, then find a lineup and get the channels from it. With the channels you can feed the search method.

    Here is an updated code for accessing the epg :

     

      private void searchTVbyChannel(Channel c, DateTime startTime, DateTime endTime)
            {
                if (!isTVenabled) { return; }

                startTime = TimeZone.CurrentTimeZone.ToUniversalTime(startTime);
                endTime = TimeZone.CurrentTimeZone.ToUniversalTime(endTime);

                try
                {
                    ScheduleEntry[] entries = c.Service.GetScheduleEntriesBetween(startTime, endTime);

                    foreach (ScheduleEntry e in entries)
                    {
                        //do something with e here

                    }
                }
                catch (NullReferenceException ex) { }
               
     }

     

     ObjectStore TVstore;

            void getStore()
            {
                writeLog("getStore");
                string basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Microsoft\eHome\");

                if (Directory.Exists(basePath))
                {
                    DirectoryInfo dir = new DirectoryInfo(basePath);
                    try
                    {
                        FileInfo dbfile = dir.GetFiles("*.db").OrderByDescending(f => f.LastWriteTime).First();

                        if (dbfile != null)
                        {
                            TVstore = ObjectStore.Open(dbfile.FullName);
                            writeLog("store ok");
                        }
                    }
                    catch (InvalidOperationException ex) { }
                }
            }

     

    MergedLineup TVlineup;

            void getLineup()
            {
                writeLog("getLineup");
                if (TVstore != null)
                {
                    MergedLineups mls = new MergedLineups(TVstore);

                    Lineups ll = new Lineups(TVstore);

                    List<MergedLineup> m = mls.ToList();
                    writeLog("lineups found: " + m.Count.ToString());
                    if (m.Count == 1)
                    {
                        TVlineup = mls.First;
                        writeLog("linup ok");
                    }
                    else if (m.Count > 1)
                    {
                        TVlineup = mls.First;
                        writeLog("lineup ok, but found more than one lineup");
                    }
                    else
                    {
                        writeLog("lineup error: no lineups");
                    }

                }
            }

     

    List<mChannel> TVChannels;

     void getChannels()
            {
                writeLog("getChannels");

                TVChannels = new List<mChannel>();

                List<Channel> test = TVlineup.GetGridChannels();


                if (TVlineup != null)
                {
                    Channel[] channels = TVlineup.GetChannels();
                    foreach (Channel channel in channels)
                    {
                        if (!channel.IsBlocked) //kanal vom benutzer deaktiviert = IsBlocked
                        {
                            StoredObject so = (StoredObject)channel;
                            mChannel mchannel = new mChannel();


                            //mchannel.MappedChannel = TVlineup.GetMappedChannel(channel);
                            //mchannel.MappedChannel = TVlineup.GetMergedChannel(channel, false);
                            //mchannel.MergedChannel = TVlineup.GetReferencingChannel(channel, false);



                            mchannel.Index = TVChannels.Count;
                            mchannel.Channel = channel;
                            mchannel.StoredObjectID = so.Id;
                            mchannel.CallSign = channel.CallSign;
                            mchannel.ChannelNumber = channel.DisplayChannelNumber;
                            TVChannels.Add(mchannel);
                        }
                    }
                    //debug
                    foreach (mChannel c in TVChannels)
                    {
                        writeLog(c.Channel.CallSign + " | " + c.Channel.DisplayChannelNumber);
                        if (c.Channel.Service == null)
                        {
                            writeLog("no service");
                        }
                        else
                        {
                            writeLog("service ok");
                        }
                    }
                    writeLog("Channels: " + TVChannels.Count.ToString());
                    writeLog("getChannels ok");
                }
                else
                {
                    writeLog("getChannels error: noLineup");
                }
                IsGettingChannels = false;
            }

  •  

    Thanks for that.

    The reason I wanted to access the channels information was because, under VMC, I was tired of using the provided guide listing re-order facility and developed my own WPF application to make guide re-ordering very easy and quick by using two listboxes and allowing the user to drag and drop channels to the preferred order and then saving the guide listing order. I needed this because VMC resets the guide listing back to the default settings at the drop of a hat. I also developed a tuner facility that allows an infinite number of tuners to be processed by VMC. The key to all this was that the database was not password protected.

    Now, under 7MC, as you say, the database is password protected. Therefore, until the password is made known there is no point in me persuing a solution further. Thank for your intervention and I look forward to hearing from you if you come across anything that might help me.

    Do you know whether anyone has figured out how to get more than 4 digital tuners to work under 7MC? I currently use 8 digital tuners under VMC and cannot upgrade to 7MC until I can use all 8 tuners.

    Thanks again, your help is much appreciated.

  •  

    I think my need is similar and would appreciate a confirmation from you experienced guys.

    Problem:  I have to constantly maintenance my guide to remove channels I don't want over and over.  I have used disable channel and edit sources methods to remove the channel, and with some frequency, the channel reappears.  In worst cases, an existing channel is overwritten with a completely different channel.  (My NBC channel became PBS, after a new source was added to my NBC listing.)

    I was thinking of developing a service that would detect a change to the guide, back out the change, and then send the new setting to a queue.  I'd have a UI to review the queue to either accept or decline the change.  Since none of the guide channel changes have never been beneficial, the queue is probably a phase 2 item.

    I am a developer, but have zero experience with Media Center apps.  Before I spend much time learning my way through this, is this already a dead-end? 

    The GuideTool application has similar functionality, but it doesn't monitor the guide as a service. And I read GuideTool accesses the guide as an MC Add In, which (i think) means I could still end-up with PBS recordings instead of NBC because an Add In can't be constantly running in the background.

  •  

    I developed a windows service for VMC to handle the changes to the guide order when it was reset to the default order by Windows Media Center. Since this application updates the .sdf database, this is not currently possible under 7MC. I also developed a UI to review and re-order the guide listing. Again, that will not work in 7MC.

     Therefore, until Microsoft give us developers an 'IN', anyone who wants to keep control of their Windows Media Center environment will have to stick with VMC.

     Hugely disappointing; and I can't for the life of me understand why Microsoft feel the need to be so prescriptive.

  •  

    Ok, so I'm dredging up an old thread. Anyways, as lopez1de said, can't you access the database as long as you do it from an add-in? Wouldn't a guide tool be an add-in? Seems like it should be possible unless I'm missing something.

    Likewise vmcuser813 should be able to implement his tool as an add-in rather than a service. So he could just run it when needed rather than having it continually run in the background.

    I came across this thread because I also need better access to guide data than what is provided in the API. When it is said that an add-in can access the encrypted database, does that include a Media Center background application, or just a local application (http://msdn.microsoft.com/en-us/library/ee525789.aspx)? With a background application, Media Center would need to be running, but at least the add-in wouldn't need to be manually invoked in order to run it (at least that's how I understand it).

  •  

    The guide database is protected so that the data can only be used by Media Center - this will be a contractual requirement that Microsoft have with the provider of the data.  However, "used by Media Center" means any code running from within an assembly signed as part of Media Center, which includes ehExtHost.exe.   This assembly is the host for all Media Center add-ins, so if you are writing either a foreground or background add-in you'll have access to the data.    If you're writing a service that runs outside of Media Center you won't have access to the data unless you can work out how to access the data directly in the database (and work out the password to the database).

    Cheers,
    Andrew

  •  

    Hi,

    Has anyone been able to run the code lopez1de posted above on a Windows 7 64bit machine? I get the same NullReferenceException when GetScheduleEntriesBetween() is executed as discussed in http://social.msdn.microsoft.com/Forums/en/netfx64bit/thread/ea979075-f602-475d-b485-3a4f787dcb70, but I have not found a solution for it.

    Regards,
    Seel

  •  

    Tony Vaughan

    Thanks for that.

    The reason I wanted to access the channels information was because, under VMC, I was tired of using the provided guide listing re-order facility and developed my own WPF application to make guide re-ordering very easy and quick by using two listboxes and allowing the user to drag and drop channels to the preferred order and then saving the guide listing order. I needed this because VMC resets the guide listing back to the default settings at the drop of a hat. I also developed a tuner facility that allows an infinite number of tuners to be processed by VMC. The key to all this was that the database was not password protected.

    Now, under 7MC, as you say, the database is password protected. Therefore, until the password is made known there is no point in me persuing a solution further. Thank for your intervention and I look forward to hearing from you if you come across anything that might help me.

    Do you know whether anyone has figured out how to get more than 4 digital tuners to work under 7MC? I currently use 8 digital tuners under VMC and cannot upgrade to 7MC until I can use all 8 tuners.

    Thanks again, your help is much appreciated.

    Search for Tuner Salad.

    Mike

    Win7 Ultimate x32 SP1, Harmony 700, Comcast Houston (cable co), Cooler Master Elite 360 Mini Tower case on it's side, ASUS M4A87TD-USB3 MB, AMD Phenom II 555 Black DualCore, 4G RAM, PNY GT440 1gb DDR5, 160GB SATA II (OS) - AHCI, 1TB SATA II (DATA) - AHCI, LG GGC-H20LK Combo drive, TMT3, Ceton InfiniTV 4, Onkyo TX-SR608, Samsung PN50C550

  •  

    Hi Andrew

    It is because of the graphical limitations of the add-in that I developed a WPF application to provide a user friendly user interface to use and manipulate the VMC database.

    As it happens, my application uses windows services and a UI application.

    Your point about contractual reasons for the database being protected seems a likely explanation, though I cannot see why this should be necessary. Is there a list of authorized developers to whom access might be given?

     Tony

  •  

    Hi Mike

    Is this some kind of special code?

    Tony

  •  

    Tuner Salad is an app that removes the restrictions on the number of tuners a machine can have.

    Cheers,
    Andrew

  •  

    Hi Andrew

    I get it. Thanks for the info.

    I've downloaded it and will set up an environment to test it.

    Thanks again.

    Tony

Page 1 of 2 (18 items) 12