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

Diff of /trunk/GBPVRProgramDatabaseFixer/Program.cs

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

--- trunk/GBPVRProgramDatabaseFixer/Program.cs	2013/03/14 19:41:32	158
+++ trunk/GBPVRProgramDatabaseFixer/Program.cs	2013/03/14 20:26:05	159
@@ -2,12 +2,14 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using System.Linq;
 using Enterprise.Logging;
 using System.Windows.Forms;
 using System.Diagnostics;
 using System.IO;
 using libxmltv.Core;
-
+using libxmltv.Interfaces;
+using libxmltv;
 namespace GBPVRProgramDatabaseFixer
 {
     class Program
@@ -170,21 +172,62 @@
 
 
         static List<SQLLITE.IPROGRAMME> gbpvr_programs;
+        static List<SQLLITE.ICHANNEL> gbpvr_channels;
         static List<SQLLITE.IRECORDING_SCHEDULE> gbpvr_recordings;
-        static List<libxmltv.Interfaces.IXMLTVProgram> xmltv_programs;
+        static IProgramDefinitionList xmltv_programs;
         static void PerformDatabaseProcessing()
         {
+            gbpvr_channels = sqlite.Channels;
             gbpvr_programs = sqlite.Programs;
-            gbpvr_recordings = sqlite.Recordings;
-            xmltv_programs = XMLTV.GetPrograms();
+            gbpvr_recordings = sqlite.Recordings;            
+            Type datatype;
+            xmltv_programs = (IProgramDefinitionList)XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out datatype);
             CheckScheduledRecordingsForDiscrepancies();
             CheckProgramsForDiscrepancies();
         }
 
         static void CheckScheduledRecordingsForDiscrepancies()
         {
-            gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");
+            //gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");
+            var manual_gbpvr_recordings = gbpvr_recordings.FindAll(p => p.recording_type == 0).ToList();
+
+            foreach (var manual_recording in manual_gbpvr_recordings)
+            {
+                string title = manual_recording.filename;
+                DateTime start = manual_recording.manual_start_time;
+                DateTime end = manual_recording.manual_end_time;
+
+                var found_program = xmltv_programs.ToList().Find(p => 
+                    p.Title.ToLower() == title.ToLower() && 
+                    p.Start == start.ToDateTimeString() &&
+                    p.Stop == end.ToDateTimeString()
+                    );
+
+                if (found_program != null)
+                {
+                    gLog.Info.WriteLine("Recording might be valid: oid='{0}' programme_oid='{1}' title='{2}' start='{3}', end='{4}'", manual_recording.oid, manual_recording.programme_oid, title, start.ToDateTimeString(), end.ToDateTimeString());
+                }
+                else
+                {
+                    gLog.Warn.WriteLine("Recording may not be valid: oid='{0}' programme_oid='{1}' title='{2}' start='{3}', end='{4}'", manual_recording.oid, manual_recording.programme_oid, title, start.ToDateTimeString(), end.ToDateTimeString());
+                }
+                //bool entry_valid = false;
+                //if (found_programs.Count == 0)
+                //{
+                //    gLog.Warn.WriteLine("Could not find an XMLTV Program with title: '{0}'", title);
+                //}
+                //foreach (var found_program in found_programs)
+                //{                    
+                //    entry_valid = (found_program.Start == start.ToDateTimeString());
+                //    entry_valid = (found_program.Stop == end.ToDateTimeString());
+                //}
+                //if (!entry_valid)
+                //{
+                //    gLog.Warn.WriteLine("Recording: oid='{0}' programme_oid='{1}' title='{2}' start='{3}', end='{4}' may not be valid", manual_recording.oid, manual_recording.programme_oid, title, start.ToDateTimeString(), end.ToDateTimeString());
+                //}
+            }
         }
+
         static void CheckProgramsForDiscrepancies()
         {
             gLog.Warn.WriteLine("CheckProgramsForDiscrepancies() has not been implemented");

 

  ViewVC Help
Powered by ViewVC 1.1.22