/[xmltv_parser]/trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs
ViewVC logotype

Diff of /trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/16 14:31:24	171
+++ trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/16 15:15:33	172
@@ -315,20 +315,33 @@
                 var channel_oid = program.channel_oid;
                 var channel = this.Channels.Find(s => s.oid == channel_oid);
                 var start_date = program.start_time;
-                var xmltv_entry_list = xmltv_programs.FindAll(s => s.ChannelNumber == channel.channel_number && s.Start == start_date.ToDateTimeString());
+                //var xmltv_entry_list = xmltv_programs.FindAll(s => s.ChannelNumber == channel.channel_number && s.Start == start_date.ToDateTimeString());
+                var query = from c in xmltv_programs 
+                            where 
+                            c.ChannelNumber == channel.channel_number &&
+                            c.Start == start_date.ToDateTimeString()
+                            select c;
+
                 IProgramDefinition xmltv_entry = null;
-                if (xmltv_entry_list.Count > 0)
+                if (query.Count()-1 > 0)
                 {
                     gLog.Error.WriteLine("Found more than one entry: Matching channel='{0}' and start='{1}'", channel.channel_number, start_date.ToDateTimeString());
                     gLog.Error.WriteLine("    GB-PVR Program Data: oid='{0}' channel_oid='{1}' name='{2}' sub_title='{3}' description='{4}'", program.oid, program.channel_oid, program.name, program.sub_title, program.description);
                     if (Debugger.IsAttached)
-                    {
+                    {                      
+                        gLog.Error.WriteLine("    Found: {0} matching entries", query.Count());
+                        int k_index = 0;
+                        foreach (var k in query)
+                        {
+                            gLog.Error.WriteLine("    query[{0}]: channel='{1}' start='{2}' ('{3}') title='{4}' subtitle='{5}' description='{6}'", k_index, k.ChannelNumber, k.Start, DateTime.Parse(k.Start).ToString("yyyy/MM/dd HH:mm:ss.fffffff"), k.Title, k.SubTitle, k.Description);
+                            k_index++;
+                        }
                         Debugger.Break();
                     }
                 }
                 else
                 {
-                    xmltv_entry = xmltv_entry_list.FirstOrDefault();
+                    xmltv_entry = query.FirstOrDefault();
                 }
 
                 if (xmltv_entry == null)
@@ -338,14 +351,43 @@
                 }
                 else
                 {
+                    gLog.Warn.WriteLine("Updating GB-PVR Program (if needed): oid='{0}' channel_oid='{1}' title='{2}' subtitle='{3}' start='{4}'", program.oid, program.channel_oid, program.name, program.sub_title, program.start_time.ToDateTimeString());
                     var updated_program = program;
-                    updated_program.description = xmltv_entry.Description;
-                    updated_program.end_time = DateTime.Parse(xmltv_entry.Stop);
-                    updated_program.name = xmltv_entry.Title;
-                    updated_program.start_time = DateTime.Parse(xmltv_entry.Start);                    
-                    updated_program.sub_title = xmltv_entry.SubTitle;
-                    gLog.Warn.WriteLine("Updating GB-PVR Program: oid='{0}' channel_oid='{1}' title='{2}' subtitle='{3}' start='{4}'", program.oid, program.channel_oid, program.name,program.sub_title, program.start_time.ToDateTimeString());
-                    gLog.Warn.WriteLine("    Updated with Program: title='{0}' subtitle='{1}' start='{2}'", updated_program.name,updated_program.sub_title, program.start_time.ToDateTimeString());
+                    if (xmltv_entry.Description != program.description)
+                    {
+                        gLog.Warn.WriteLine("    Updating:");
+                        gLog.Warn.WriteLine("        Old Descption: {0}", program.description);
+                        gLog.Warn.WriteLine("        New Descption: {0}", xmltv_entry.Description);
+                        updated_program.description = xmltv_entry.Description;                        
+                    }
+                    if (DateTime.Parse(xmltv_entry.Stop) != program.end_time)
+                    {
+                        gLog.Warn.WriteLine("    Updating:");
+                        gLog.Warn.WriteLine("        Old EndTime: {0}", program.end_time.ToDateTimeString());
+                        gLog.Warn.WriteLine("        New EndTime: {0}", DateTime.Parse(xmltv_entry.Stop).ToDateTimeString());
+                        updated_program.end_time = DateTime.Parse(xmltv_entry.Stop);
+                    }
+                    if (xmltv_entry.Title != program.name)
+                    {
+                        gLog.Warn.WriteLine("    Updating:");
+                        gLog.Warn.WriteLine("        Old Title: {0}", program.name);
+                        gLog.Warn.WriteLine("        New Title: {0}", xmltv_entry.Title);
+                        updated_program.name = xmltv_entry.Title;
+                    }
+                    if (DateTime.Parse(xmltv_entry.Start) != program.start_time)
+                    {
+                        gLog.Warn.WriteLine("    Updating:");
+                        gLog.Warn.WriteLine("        Old StartTime: {0}", program.start_time.ToDateTimeString());
+                        gLog.Warn.WriteLine("        New StartTime: {0}", DateTime.Parse(xmltv_entry.Start).ToDateTimeString());
+                        updated_program.start_time = DateTime.Parse(xmltv_entry.Start);                    
+                    }
+                    if (xmltv_entry.SubTitle != program.sub_title)
+                    {
+                        gLog.Warn.WriteLine("    Updating:");
+                        gLog.Warn.WriteLine("        Old SubTile: {0}", program.sub_title);
+                        gLog.Warn.WriteLine("        New SubTile: {0}", xmltv_entry.SubTitle);
+                        updated_program.sub_title = xmltv_entry.SubTitle;
+                    }
                     source_valid.Add(updated_program);
                 }
                 index++;

 

  ViewVC Help
Powered by ViewVC 1.1.22