Ticket #8916: 8916-mythfilldatabase-clear-listings.diff

File 8916-mythfilldatabase-clear-listings.diff, 2.3 KB (added by Nick Morrott <knowledgejunkie <at> gmail <dot> com>, 10 years ago)

Add option to clear listings data

  • mythtv/programs/mythfilldatabase/main.cpp

     
    6060    int sourceid = -1;
    6161    QString fromddfile_lineupid;
    6262
     63    bool clearListings = false;
     64
    6365    QFileInfo finfo(a.argv()[0]);
    6466    QString binname = finfo.baseName();
    6567
     
    275277        {
    276278            fill_data.only_update_channels = true;
    277279        }
     280        else if (!strcmp(a.argv()[argpos], "--clear-listings"))
     281        {
     282            clearListings = true;
     283            grab_data = false;
     284            mark_repeats = false;
     285        }
    278286        else if (!strcmp(a.argv()[argpos],"-v") ||
    279287                 !strcmp(a.argv()[argpos],"--verbose"))
    280288        {
     
    488496            cout << "   Marks any programs with a OriginalAirDate earlier\n";
    489497            cout << "   than their start date as a repeat\n";
    490498            cout << "\n";
     499            cout << "--clear-listings\n";
     500            cout << "   Deletes listings data for all video sources\n";
     501            cout << "\n";
    491502            cout << "-v or --verbose debug-level\n";
    492503            cout << "   Use '-v help' for level info\n";
    493504            cout << "\n";
     
    926937        VERBOSE(VB_GENERAL, QString("    Found %1").arg(found));
    927938    }
    928939
     940    if (clearListings)
     941    {
     942        VERBOSE(VB_GENERAL, "Deleting listings for all video sources.");
     943        MSqlQuery query(MSqlQuery::InitCon());
     944        query.exec("TRUNCATE TABLE credits;");
     945        query.exec("TRUNCATE TABLE eit_cache;");
     946        query.exec("TRUNCATE TABLE people;");
     947        query.exec("TRUNCATE TABLE program;");
     948        query.exec("TRUNCATE TABLE programgenres;");
     949        query.exec("TRUNCATE TABLE programrating;");
     950    }
     951
    929952    if (1) // limit MSqlQuery's lifetime
    930953    {
    931954        MSqlQuery query(MSqlQuery::InitCon());
     
    963986            "| the master backend is restarted.                            |\n"
    964987            "===============================================================");
    965988
    966     if (grab_data || mark_repeats)
     989    if (grab_data || mark_repeats || clearListings)
    967990        ScheduledRecording::signalChange(-1);
    968991
    969992    RemoteSendMessage("CLEAR_SETTINGS_CACHE");