Index: programs/mythfilldatabase/filldata.cpp
===================================================================
--- programs/mythfilldatabase/filldata.cpp	(revision 9955)
+++ programs/mythfilldatabase/filldata.cpp	(working copy)
@@ -3881,6 +3881,50 @@
                 QString("    Found %1").arg(query.numRowsAffected()));
     }
 
+    if (grab_data)
+    {
+        VERBOSE(VB_GENERAL, "Fudging non-unique programid "
+                "with multiple parts.");
+
+        MSqlQuery sel(MSqlQuery::InitCon());
+        sel.exec("SELECT DISTINCT programid, partnumber "
+                   "FROM program WHERE partnumber > 0 AND parttotal > 0 AND "
+                   "programid LIKE '%0000'");
+
+        if (sel.isActive() && sel.size() > 0)
+        {
+            MSqlQuery repl(MSqlQuery::InitCon());
+
+            while (sel.next())
+            {
+                QString orig_programid = sel.value(0).toString();
+                int partnum = sel.value(1).toInt();
+                QString new_programid = orig_programid.left(8);
+                QString part;
+
+                part.setNum(partnum);
+                new_programid.append(part.rightJustify(4, '0'));
+
+                repl.prepare("UPDATE program SET programid = :NEWID "
+                             "WHERE programid = :OLDID AND "
+                             "partnumber = :PART");
+                repl.bindValue(":NEWID", new_programid);
+                repl.bindValue(":OLDID", orig_programid);
+                repl.bindValue(":PART", partnum);
+                if (!repl.exec())
+                {
+                    MythContext::DBError(QString("Fudging programid from '%1' "
+                                                 " to '%2'")
+                                         .arg(orig_programid)
+                                         .arg(new_programid), repl);
+                }
+            }
+        }
+
+        VERBOSE(VB_GENERAL,
+                QString("    Found %1").arg(sel.numRowsAffected()));
+    }
+
     if (mark_repeats)
     {
         VERBOSE(VB_GENERAL, "Marking repeats.");
