/[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

revision 158 by william, Thu Mar 14 19:41:32 2013 UTC revision 159 by william, Thu Mar 14 20:26:05 2013 UTC
# Line 2  Line 2 
2  using System;  using System;
3  using System.Collections.Generic;  using System.Collections.Generic;
4  using System.Text;  using System.Text;
5    using System.Linq;
6  using Enterprise.Logging;  using Enterprise.Logging;
7  using System.Windows.Forms;  using System.Windows.Forms;
8  using System.Diagnostics;  using System.Diagnostics;
9  using System.IO;  using System.IO;
10  using libxmltv.Core;  using libxmltv.Core;
11    using libxmltv.Interfaces;
12    using libxmltv;
13  namespace GBPVRProgramDatabaseFixer  namespace GBPVRProgramDatabaseFixer
14  {  {
15      class Program      class Program
# Line 170  namespace GBPVRProgramDatabaseFixer Line 172  namespace GBPVRProgramDatabaseFixer
172    
173    
174          static List<SQLLITE.IPROGRAMME> gbpvr_programs;          static List<SQLLITE.IPROGRAMME> gbpvr_programs;
175            static List<SQLLITE.ICHANNEL> gbpvr_channels;
176          static List<SQLLITE.IRECORDING_SCHEDULE> gbpvr_recordings;          static List<SQLLITE.IRECORDING_SCHEDULE> gbpvr_recordings;
177          static List<libxmltv.Interfaces.IXMLTVProgram> xmltv_programs;          static IProgramDefinitionList xmltv_programs;
178          static void PerformDatabaseProcessing()          static void PerformDatabaseProcessing()
179          {          {
180                gbpvr_channels = sqlite.Channels;
181              gbpvr_programs = sqlite.Programs;              gbpvr_programs = sqlite.Programs;
182              gbpvr_recordings = sqlite.Recordings;              gbpvr_recordings = sqlite.Recordings;            
183              xmltv_programs = XMLTV.GetPrograms();              Type datatype;
184                xmltv_programs = (IProgramDefinitionList)XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out datatype);
185              CheckScheduledRecordingsForDiscrepancies();              CheckScheduledRecordingsForDiscrepancies();
186              CheckProgramsForDiscrepancies();              CheckProgramsForDiscrepancies();
187          }          }
188    
189          static void CheckScheduledRecordingsForDiscrepancies()          static void CheckScheduledRecordingsForDiscrepancies()
190          {          {
191              gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");              //gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");
192                var manual_gbpvr_recordings = gbpvr_recordings.FindAll(p => p.recording_type == 0).ToList();
193    
194                foreach (var manual_recording in manual_gbpvr_recordings)
195                {
196                    string title = manual_recording.filename;
197                    DateTime start = manual_recording.manual_start_time;
198                    DateTime end = manual_recording.manual_end_time;
199    
200                    var found_program = xmltv_programs.ToList().Find(p =>
201                        p.Title.ToLower() == title.ToLower() &&
202                        p.Start == start.ToDateTimeString() &&
203                        p.Stop == end.ToDateTimeString()
204                        );
205    
206                    if (found_program != null)
207                    {
208                        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());
209                    }
210                    else
211                    {
212                        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());
213                    }
214                    //bool entry_valid = false;
215                    //if (found_programs.Count == 0)
216                    //{
217                    //    gLog.Warn.WriteLine("Could not find an XMLTV Program with title: '{0}'", title);
218                    //}
219                    //foreach (var found_program in found_programs)
220                    //{                    
221                    //    entry_valid = (found_program.Start == start.ToDateTimeString());
222                    //    entry_valid = (found_program.Stop == end.ToDateTimeString());
223                    //}
224                    //if (!entry_valid)
225                    //{
226                    //    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());
227                    //}
228                }
229          }          }
230    
231          static void CheckProgramsForDiscrepancies()          static void CheckProgramsForDiscrepancies()
232          {          {
233              gLog.Warn.WriteLine("CheckProgramsForDiscrepancies() has not been implemented");              gLog.Warn.WriteLine("CheckProgramsForDiscrepancies() has not been implemented");

Legend:
Removed from v.158  
changed lines
  Added in v.159

  ViewVC Help
Powered by ViewVC 1.1.22