[mythtv] mythfilldatabase patch to improve handling of zero-length programs

Rudy Eschauzier rudy at eschauzier.org
Tue Apr 20 03:13:23 EDT 2004


The patch below contains two enhancements to mythfilldatabase:

1. Improved handling of zero-length program entries.

Currently, zero-length program entries cause problems in mythfilldatabase,
skipping valid program entries around the zero-length program.

The problem originates from fixProgramList(), where zero-length programs
are allowed to take priority over valid program entries in case of a time
conflict.

This can be seen in the following example using tv_grab_nl. The first pdf
shows the upstream tv-guide data for "Nederland 3" with
zero-length programs at 07:00h, 07:20h, 08:35h, 09:00h and 13:00h:

ftp://ftp.eschauzier.org/pub/tvguide.pdf

The resulting MythWeb output with MythTV 0.14 is shown here:

ftp://ftp.eschauzier.org/pub/mythweb-0.14.pdf

Notice the "NO DATA" entries for "Ned 3" around the times of the
zero-length program entries

With the patch, the output of MythWeb looks like this:

ftp://ftp.eschauzier.org/pub/mythweb-patch.pdf

with all the "NO DATA" entries gone.


2. Addition of the "graboptions" command line option

This addition allows for command line options to be passed to the actual
XMLTV grabber command. This is useful for the tv_grab_nl grabber for
example, which includes a "--slow" option to do an exhausive grab of the
upstream site. An example of using the new command line option would be:

mythfilldatabase --update --graboptions "--slow"

I have followed the original programming as much as possible, trying to
keep the side effects of the changes to a minimum. Please review and give
me your comments.

The patch is made against rev. 0.14 of MythTV.

Rudy Eschauzier




-------------- next part --------------
--- filldata.cpp-0.14	2004-04-10 19:38:02.000000000 +0200
+++ filldata.cpp	2004-04-17 15:30:30.000000000 +0200
@@ -40,6 +40,7 @@
 bool refresh_tomorrow = true;
 bool refresh_second = false;
 int listing_wrap_offset = 0;
+QString graboptions="";
 
 class ChanInfo
 {
@@ -605,7 +606,9 @@
 bool conflict(ProgInfo &a, ProgInfo &b)
 {
     if ((a.start <= b.start && b.start < a.end) ||
-        (b.end <= a.end && a.start < b.end))
+        (b.end <= a.end && a.start < b.end) ||
+// two programs starting or ending at the same time constitutes a conflict
+         a.start == b.start || a.end == b.end)
         return true;
     return false;
 }
@@ -644,7 +647,13 @@
         {
             QValueList<ProgInfo>::iterator tokeep, todelete;
 
-            if((*cur).subtitle != "" && (*i).subtitle == "")
+            // a zero-length program may never take priority
+            if((*cur).end <= (*cur).start)
+                tokeep = i, todelete = cur;
+            else if((*i).end <= (*i).start)
+                tokeep = cur, todelete = i;
+
+            else if((*cur).subtitle != "" && (*i).subtitle == "")
                 tokeep = cur, todelete = i;
             else if((*i).subtitle != "" && (*cur).subtitle == "")
                 tokeep = i, todelete = cur;
@@ -1332,7 +1341,7 @@
     QString configfile = QString("%1/.mythtv/%2.xmltv").arg(home)
                                                        .arg(source.name);
     QString command;
-    QString xmltv_grabber = source.xmltvgrabber;
+    QString xmltv_grabber = source.xmltvgrabber + graboptions;
 
     if (xmltv_grabber == "tv_grab_uk")
         command.sprintf("nice %s --days 7 --config-file '%s' --output %s",
@@ -1885,6 +1894,8 @@
     int fromxawfile_id = 1;
     QString fromxawfile_name;
 
+    graboptions="";
+
     while (argpos < a.argc())
     {
         // The manual and update flags should be mutually exclusive.
@@ -1954,6 +1965,16 @@
                  cout << "### reading channels from xawtv configfile\n";
             from_xawfile = true;
         }
+        else if (!strcmp(a.argv()[argpos], "--graboptions"))
+        {
+            if (((argpos + 1) >= a.argc()))
+            {
+                printf("missing parameter for --graboptions option\n");
+                return -1;
+            }
+
+            graboptions = QString(" ")+QString(a.argv()[++argpos]);
+        }
         else if (!strcmp(a.argv()[argpos], "--refresh-today"))
         {
             refresh_today = true;
@@ -2006,6 +2027,9 @@
             cout << "   <sourceid>    = cardinput\n";
             cout << "   <xawtvrcfile> = file to read\n";
             cout << "\n";
+            cout << "--graboptions <\"options\">\n";
+            cout << "   Pass options to grabber\n";
+            cout << "\n";
             cout << "--refresh-today\n";
             cout << "--refresh-second\n";
             cout << "   (Only valid for grabbers: na/uk_rt/sn)\n";


More information about the mythtv-dev mailing list