[mythtv] conflict resolution

David Engel dlengel at attbi.com
Sat Nov 1 12:57:04 EST 2003


On Thu, Oct 30, 2003 at 01:04:39AM -0500, Matt Zimmerman wrote:
> On Wed, Oct 29, 2003 at 05:26:51PM -1000, James L. Paul wrote:
> > Having the ProgramInfo record, what's a good simple way to cause a 
> > specific program to be suppressed?
> 
> Implement overrides, as discussed in detail several times on this list.

I'm going to take a stab at this.  I have a proof of concept patch
(below) to see that the scheduler can do the right thing.  It uses a
recordoverride table as suggested previously by Matt.  The two types
of overrides are record (1) and don't record (2).

What I'd like to know before procedding any further is this.  Is this
approach going to be acceptable?  And, if so, what should the user
interface aspects look like.

David
-- 
David Engel
dlengel at attbi.com
-------------- next part --------------
Index: settings.pro
===================================================================
RCS file: /var/lib/mythcvs/mythtv/settings.pro,v
retrieving revision 1.40
diff -u -r1.40 settings.pro
--- settings.pro	23 Oct 2003 19:57:17 -0000	1.40
+++ settings.pro	1 Nov 2003 17:37:12 -0000
@@ -1,8 +1,8 @@
-#CONFIG += debug
-CONFIG += release
+CONFIG += debug
+#CONFIG += release
 
-PREFIX = /usr/local
+PREFIX = /usr/local/mythtv
 
 LIBVERSION = 0.13
 
Index: libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.72
diff -u -r1.72 programinfo.cpp
--- libs/libmythtv/programinfo.cpp	28 Oct 2003 21:48:30 -0000	1.72
+++ libs/libmythtv/programinfo.cpp	1 Nov 2003 17:37:13 -0000
@@ -31,6 +31,7 @@
     duplicate = false;
     suppressed = false;
     reasonsuppressed = QObject::tr("Not Currently Suppressed");
+    override = 0;
 
     sourceid = -1;
     inputid = -1;
@@ -65,6 +66,7 @@
     duplicate = other.duplicate;
     suppressed = other.suppressed;
     reasonsuppressed = other.reasonsuppressed;
+    override = other.override;
 
     sourceid = other.sourceid;
     inputid = other.inputid;
@@ -110,6 +112,7 @@
     list << ((rank != "") ? rank : QString(" "));
     list << QString::number(suppressed);
     list << ((reasonsuppressed != "") ? reasonsuppressed : QString(" "));
+    list << QString::number(override);
 }
 
 void ProgramInfo::FromStringList(QStringList &list, int offset)
@@ -143,6 +146,7 @@
     rank = list[offset + 20];
     suppressed = list[offset + 21].toInt();
     reasonsuppressed = list[offset + 22];
+    override = list[offset + 23].toInt();
 
     if (title == " ")
         title = "";
Index: libs/libmythtv/programinfo.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.h,v
retrieving revision 1.49
diff -u -r1.49 programinfo.h
--- libs/libmythtv/programinfo.h	13 Aug 2003 15:28:51 -0000	1.49
+++ libs/libmythtv/programinfo.h	1 Nov 2003 17:37:13 -0000
@@ -174,6 +174,7 @@
     bool duplicate;
     bool suppressed;
     QString reasonsuppressed;
+    int override;
 
     int sourceid;
     int inputid;
Index: libs/libmythtv/scheduledrecording.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.cpp,v
retrieving revision 1.44
diff -u -r1.44 scheduledrecording.cpp
--- libs/libmythtv/scheduledrecording.cpp	3 Oct 2003 07:35:00 -0000	1.44
+++ libs/libmythtv/scheduledrecording.cpp	1 Nov 2003 17:37:13 -0000
@@ -237,7 +237,7 @@
 "channel.channum, channel.callsign, channel.name, "
 "oldrecorded.starttime IS NOT NULL AS oldrecduplicate, program.category, "
 "record.rank, record.recorddups, "
-"recorded.starttime IS NOT NULL as recduplicate, record.type "
+"recorded.starttime IS NOT NULL as recduplicate, record.type, recordoverride.type "
 "FROM record "
 " INNER JOIN channel ON (channel.chanid = program.chanid) "
 " INNER JOIN program ON (program.title = record.title) "
@@ -257,6 +257,15 @@
 "     AND "
 "    recorded.description IS NOT NULL AND recorded.description <> '' AND program.description = recorded.description"
 "  ) "
+" LEFT JOIN recordoverride ON "
+"  ( "
+"    program.chanid = recordoverride.chanid "
+"    AND program.starttime = recordoverride.starttime "
+"    AND program.endtime = recordoverride.endtime "
+"    AND program.title = recordoverride.title "
+"    AND program.subtitle = recordoverride.subtitle "
+"    AND program.description = recordoverride.description "
+"  ) "
 "WHERE "
 "((record.type = %1) " // allrecord
 " OR "
@@ -308,6 +317,7 @@
              proginfo->chanstr = result.value(7).toString();
              proginfo->chansign = result.value(8).toString();
              proginfo->channame = result.value(9).toString();
+	     proginfo->override = result.value(16).toInt();
 
              if (result.value(15).toInt() == kSingleRecord)
              {
@@ -324,7 +334,8 @@
                      proginfo->duplicate = result.value(10).toInt();
              }
 
-             if (proginfo->duplicate)
+             if ((proginfo->duplicate && proginfo->override != 1)
+		 || proginfo->override == 2)
                  proginfo->recording = false;
 
              proginfo->category = QString::fromUtf8(result.value(11).toString());
@@ -344,11 +355,16 @@
              if (proginfo->category == QString::null)
                  proginfo->category = "";
 
+	     cout << "override=" << proginfo->override
+		  << ", chanid=" << proginfo->chanid
+		  << ", startts=" << proginfo->startts.toString(Qt::ISODate)
+		  << ", title=\"" << proginfo->title << "\""
+		  << endl;
+
              if (proginfo->endts < now)
                  delete proginfo;
              else 
                  proglist.push_back(proginfo);
-             
          }
     }
     else if (!result.isActive())
@@ -414,7 +430,6 @@
         }
 }
 
-
 bool ScheduledRecording::loadByProgram(QSqlDatabase* db,
                                        ProgramInfo* proginfo) {
     QString sqltitle(proginfo->title);
Index: programs/mythbackend/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/main.cpp,v
retrieving revision 1.44
diff -u -r1.44 main.cpp
--- programs/mythbackend/main.cpp	23 Oct 2003 22:19:39 -0000	1.44
+++ programs/mythbackend/main.cpp	1 Nov 2003 17:37:13 -0000
@@ -368,12 +368,14 @@
     if (printsched)
     {
         sched = new Scheduler(false, &tvList, db);
+#if 0
         if (gContext->ConnectToMasterServer())
         {
             cout << "Retrieving Schedule from Master backend.\n";
             sched->FillRecordListFromMaster();
         }
         else
+#endif
         {
             cout << "Calculating Schedule from database.\n" <<
                     "Inputs, Card IDs, and Conflict info may be invalid "
Index: programs/mythbackend/scheduler.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/scheduler.cpp,v
retrieving revision 1.47
diff -u -r1.47 scheduler.cpp
--- programs/mythbackend/scheduler.cpp	31 Oct 2003 04:33:11 -0000	1.47
+++ programs/mythbackend/scheduler.cpp	1 Nov 2003 17:37:13 -0000
@@ -242,7 +242,7 @@
     cout << "--- print list start ---\n";
     list<ProgramInfo *>::iterator i = recordingList.begin();
     cout << "Title                 Chan  ChID  StartTime       S I C "
-            "-- C R D S Rank Total" << endl;
+            "-- C R D S O Rank Total" << endl;
     for (; i != recordingList.end(); i++)
     {
         ProgramInfo *first = (*i);
@@ -256,6 +256,7 @@
              << " " << first->inputid << " " << first->cardid << " -- "  
              << first->conflicting << " " << first->recording << " "
              << first->duplicate << " " << first->suppressed << " "
+	     << first->override << " "
              << first->rank.rightJustify(4, ' ') << " "
              << totrank.rightJustify(4, ' ')
              << endl;
@@ -456,7 +457,7 @@
         if (first->GetProgramRecordingStatus(db) > kSingleRecord &&
             (first->subtitle.length() > 2 && first->description.length() > 2))
         {
-            if (first->duplicate)
+            if (first->duplicate && first->override != 1)
             {
                 first->recording = false;
             }
@@ -474,22 +475,36 @@
                     }
                     else if (first->IsSameProgram(*second))
                     {
-                        if ((second->conflicting && !first->conflicting) ||
-                            second->startts < now.addSecs(-15))
+                        if (((second->conflicting && !first->conflicting) ||
+			     second->startts < now.addSecs(-15) || first->override == 1) 
+			    && second->override != 1)
                         {
+			    cout << "PruneList: deleting second chanid=" << second->chanid <<
+				", startts= " << second->startts.toString(Qt::ISODate) <<
+				", title=\"" << second->title << "\"" << 
+				", subtitle=\"" << second->subtitle << "\"" << endl;
                             delete second;
                             deliter = j.base();
                             deliter--;
                             recordingList.erase(deliter);
                         }
-                        else
+                        else if (first->override != 1)
                         {
+			    cout << "PruneList: deleting first  chanid=" << first->chanid <<
+				", startts= " << first->startts.toString(Qt::ISODate) <<
+				", title=\"" << first->title << "\"" << 
+				", subtitle=\"" << first->subtitle << "\"" << endl;
                             delete first;
                             deliter = i.base();
                             deliter--;
                             recordingList.erase(deliter);
                             break;
                         }
+			else
+			{
+			    cout << "PruneList: deleting neither" << endl;
+			    j++;
+			}
                     }
                     else
                     {


More information about the mythtv-dev mailing list