[mythtv] patch to enable "no icon update" in mythfilldatabase

Roy Hooper rhooper at toybox.ca
Mon Jan 5 21:50:05 EST 2004


An annoying side effect of mythfilldatabase with incomplete xmltv data 
is that it rewrites the contents of the icon filename field in channels 
every time it is run.  I have added a --noiconupdate flag to 
mythfilldatabase in the included patch.  When run with this flag, the 
icon field isn't changed.  This is useful for people in areas missing 
icon data who have gone and fetched missing icons by hand.

Roy

-------------- next part --------------
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfilldatabase/filldata.cpp,v
retrieving revision 1.75
diff -u -r1.75 filldata.cpp
--- programs/mythfilldatabase/filldata.cpp	22 Dec 2003 02:30:55 -0000	1.75
+++ programs/mythfilldatabase/filldata.cpp	6 Jan 2004 02:37:26 -0000
@@ -32,6 +32,7 @@
 bool quiet = false;
 bool no_delete = false;
 bool isNorthAmerica = false;
+bool noIconUpdate = false;
 
 MythContext *gContext;
 
@@ -774,6 +775,7 @@
         QSqlQuery query;
 
         QString querystr;
+        QString querystrtmp;
 
         if ((*i).old_xmltvid != QString::null) {
             querystr.sprintf("SELECT xmltvid FROM channel WHERE xmltvid = \"%s\"",
@@ -849,21 +851,28 @@
                 {
                     querystr.sprintf("UPDATE channel SET chanid = %s, "
                                      "name = \"%s\", callsign = \"%s\", "
-                                     "channum = \"%s\", finetune = %d, "
-                                     "icon = \"%s\", freqid = \"%s\", "
-                                     "tvformat = \"%s\" "
-                                     "WHERE xmltvid = \"%s\" "
-                                     "AND sourceid = %d;",
+                                     "channum = \"%s\", finetune = %d, ",
                                      chanid.ascii(),
                                      (*i).name.ascii(),
                                      (*i).callsign.ascii(),
                                      (*i).chanstr.ascii(),
-                                     atoi((*i).finetune.ascii()),
-                                     localfile.ascii(),
+                                     atoi((*i).finetune.ascii()));
+                    if (!noIconUpdate) {
+                        querystrtmp.sprintf(
+                                     "icon = \"%s\", ",
+                                     localfile.ascii());
+                        querystr += querystrtmp;
+                    }
+                    querystrtmp.sprintf(
+                                     "freqid = \"%s\", "
+                                     "tvformat = \"%s\" "
+                                     "WHERE xmltvid = \"%s\" "
+                                     "AND sourceid = %d;",
                                      (*i).freqid.ascii(),
                                      (*i).tvformat.ascii(),
                                      (*i).xmltvid.ascii(),
                                      id);
+                    querystr += querystrtmp;
 
                     if (!query.exec(querystr))
                     {
@@ -889,15 +898,17 @@
             {
                 if (!non_us_updating)
                 {
-                    querystr.sprintf("UPDATE channel SET icon = \"%s\" WHERE "
-                                     "chanid = \"%s\"",
-                                     localfile.ascii(), chanid.ascii());
+                    if (!noIconUpdate) {
+                        querystr.sprintf("UPDATE channel SET icon = \"%s\" WHERE "
+                                         "chanid = \"%s\"",
+                                         localfile.ascii(), chanid.ascii());
 
-                    if (!query.exec(querystr))
-                    {
-                        cerr << "DB Error: Channel icon change failed, SQL query "
-                             << "was:" << endl;
-                        cerr << querystr << endl;
+                        if (!query.exec(querystr))
+                        {
+                            cerr << "DB Error: Channel icon change failed, SQL query "
+                                 << "was:" << endl;
+                            cerr << querystr << endl;
+                        }
                     }
                 }
             }
@@ -1851,6 +1862,12 @@
             // users in xmltv zones that do not provide channel data.
             non_us_updating = true;
         }
+        else if (!strcmp(a.argv()[argpos], "--noiconupdate"))
+        {
+            // For running non-destructive updates on the database for
+            // users in xmltv zones that do not provide channel data.
+            noIconUpdate = true;
+        }
         else if (!strcmp(a.argv()[argpos], "--no-delete"))
         {
             // Do not delete old programs from the database until 7 days old.


More information about the mythtv-dev mailing list