Ticket #3842: 3842-multilineup-head-v1.patch

File 3842-multilineup-head-v1.patch, 11.9 KB (added by danielk, 18 years ago)

Prevents digital channels from being added to analog lineups by default.

  • libs/libmythtv/datadirect.h

     
    324324    static void UpdateProgramViewTable(uint sourceid);
    325325
    326326    // static commands (these update regular DB tables from temp DB tables)
    327     static int  UpdateChannelsSafe(uint sourceid, bool insert_channels);
    328     static bool UpdateChannelsUnsafe(uint sourceid);
     327    static int  UpdateChannelsSafe(
     328        uint sourceid, bool insert_channels, bool filter_new_channels);
     329    static bool UpdateChannelsUnsafe(
     330        uint sourceid, bool filter_new_channels);
    329331    static void DataDirectProgramUpdate(void);
    330332
    331333    // static command, makes Labs and Schedules Direct ProgramIDs compatible.
  • libs/libmythtv/sourceutil.h

     
    1616    static bool    GetListingsLoginData(uint sourceid,
    1717                                        QString &grabber, QString &userid,
    1818                                        QString &passwd,  QString &lineupid);
    19     static bool    IsEncoder(uint sourceid);
     19    static bool    IsEncoder(uint sourceid, bool strict = false);
    2020    static bool    IsUnscanable(uint sourceid);
    2121    static bool    IsAnySourceScanable(void);
    2222    static bool    UpdateChannelsFromListings(
  • libs/libmythtv/datadirect.cpp

     
    4343static QString process_dd_station(uint sourceid,
    4444                                  QString  chan_major, QString  chan_minor,
    4545                                  QString &tvformat,   uint    &freqid);
    46 static void    update_channel_basic(uint    sourceid,   bool    insert,
     46static uint    update_channel_basic(uint    sourceid,   bool    insert,
    4747                                    QString xmltvid,    QString callsign,
    4848                                    QString name,       uint    freqid,
    4949                                    QString chan_major, QString chan_minor);
     
    679679        MythContext::DBError("Analyzing table dd_productioncrew", query);
    680680}
    681681
    682 int DataDirectProcessor::UpdateChannelsSafe(uint sourceid,
    683                                             bool insert_channels)
     682int DataDirectProcessor::UpdateChannelsSafe(
     683    uint sourceid,
     684    bool insert_channels,
     685    bool filter_new_channels)
    684686{
    685687    int new_channels = 0;
    686688
     
    704706        return -1;
    705707    }
    706708
     709    bool is_encoder = SourceUtil::IsEncoder(sourceid, true);
     710
    707711    while (query.next())
    708712    {
    709713        QString xmltvid    = query.value(0).toString();
     
    713717        QString chan_major = query.value(4).toString();
    714718        QString chan_minor = query.value(5).toString();
    715719
    716         update_channel_basic(sourceid, insert_channels,
    717                              xmltvid, callsign, name, freqid,
    718                              chan_major, chan_minor);
     720        if (filter_new_channels && is_encoder &&
     721            (query.value(5).toUInt() > 0))
     722        {
     723            VERBOSE(VB_GENERAL, LOC + QString(
     724                        "Not adding channel %1-%2 '%3' (%4),\n\t\t\t"
     725                        "looks like a digital channel on an analog source.")
     726                    .arg(chan_major).arg(chan_minor).arg(name).arg(callsign));
     727            continue;
     728        }
    719729
    720         if (!insert_channels)
     730        uint mods =
     731            update_channel_basic(sourceid, insert_channels && is_encoder,
     732                                 xmltvid, callsign, name, freqid,
     733                                 chan_major, chan_minor);
     734
     735        if (!insert_channels && !mods)
    721736        {
    722             VERBOSE(VB_GENERAL, LOC + QString("Not adding channel %1 (%2).")
     737            VERBOSE(VB_GENERAL, LOC + QString("Not adding channel '%1' (%2).")
    723738                    .arg(name).arg(callsign));
    724739        }
    725740        new_channels++;
     
    728743    return new_channels;
    729744}
    730745
    731 bool DataDirectProcessor::UpdateChannelsUnsafe(uint sourceid)
     746bool DataDirectProcessor::UpdateChannelsUnsafe(
     747    uint sourceid, bool filter_new_channels)
    732748{
    733749    MSqlQuery dd_station_info(MSqlQuery::DDCon());
    734750    dd_station_info.prepare(
     
    750766        "    atsc_minor_chan = :MINORCHAN "
    751767        "WHERE xmltvid = :STATIONID AND sourceid = :SOURCEID");
    752768
     769    bool is_encoder = SourceUtil::IsEncoder(sourceid, true);
     770
    753771    while (dd_station_info.next())       
    754772    {
    755773        uint    freqid     = dd_station_info.value(3).toUInt();
     
    759777        QString channum    = process_dd_station(
    760778            sourceid, chan_major, chan_minor, tvformat, freqid);
    761779
     780        if (filter_new_channels && is_encoder &&
     781            (dd_station_info.value(5).toUInt() > 0))
     782        {
     783            VERBOSE(VB_GENERAL, LOC + QString(
     784                        "Not adding channel %1-%2 '%3' (%4),\n\t\t\t"
     785                        "looks like a digital channel on an analog source.")
     786                    .arg(chan_major).arg(chan_minor)
     787                    .arg(dd_station_info.value(1).toString())
     788                    .arg(dd_station_info.value(0).toString()));
     789            continue;
     790        }
     791
    762792        chan_update_q.bindValue(":CALLSIGN",  dd_station_info.value(0));
    763793        chan_update_q.bindValue(":NAME",      dd_station_info.value(1));
    764794        chan_update_q.bindValue(":STATIONID", dd_station_info.value(2));
     
    20912121    return channum;
    20922122}
    20932123
    2094 static void update_channel_basic(uint    sourceid,   bool    insert,
     2124static uint update_channel_basic(uint    sourceid,   bool    insert,
    20952125                                 QString xmltvid,    QString callsign,
    20962126                                 QString name,       uint    freqid,
    20972127                                 QString chan_major, QString chan_minor)
     
    21242154    {
    21252155        MythContext::DBError(
    21262156            "Getting chanid of existing channel", query);
    2127         return; // go on to next channel without xmltv
     2157        return 0; // go on to next channel without xmltv
    21282158    }
    21292159
    21302160    if (query.next())
     
    21372167            "SET xmltvid = :XMLTVID, name = :NAME, callsign = :CALLSIGN "
    21382168            "WHERE chanid = :CHANID AND sourceid = :SOURCEID");
    21392169
     2170        uint i = 0;
    21402171        do
    21412172        {
    21422173            uint chanid = query.value(0).toInt();
     
    21562187            chan_update_q.bindValue(":XMLTVID",  xmltvid);
    21572188            chan_update_q.bindValue(":SOURCEID", sourceid);
    21582189
     2190            VERBOSE(VB_GENERAL, LOC +
     2191                    QString("Updating channel %1: '%2' (%3).")
     2192                    .arg(chanid).arg(name).arg(callsign));
     2193
    21592194            if (!chan_update_q.exec() || !chan_update_q.isActive())
    21602195            {
    21612196                MythContext::DBError(
    21622197                    "Updating XMLTVID of existing channel", chan_update_q);
    21632198                continue; // go on to next instance of this channel
    21642199            }
     2200            i++;
    21652201        }
    21662202        while (query.next());
    21672203
    2168         return; // go on to next channel without xmltv
     2204        return i; // go on to next channel without xmltv
    21692205    }
    21702206
    21712207    if (!insert)
    2172         return; // go on to next channel without xmltv
     2208        return 0; // go on to next channel without xmltv
    21732209
    21742210    // The channel doesn't exist in the DB, insert it...
    21752211    int mplexid = -1, majorC, minorC, chanid = 0;
     
    21832219    if ((mplexid > 0) || (minorC == 0))
    21842220        chanid = ChannelUtil::CreateChanID(sourceid, channum);
    21852221
     2222    VERBOSE(VB_GENERAL, LOC + QString("Adding channel %1 '%2' (%3).")
     2223            .arg(channum).arg(name).arg(callsign));
     2224
    21862225    if (chanid > 0)
    21872226    {
    21882227        QString icon   = "";
     
    22002239            freq_id,   icon,      tvformat,
    22012240            xmltvid);
    22022241    }
     2242
     2243    return 1;
    22032244}
    22042245
    22052246static void set_lineup_type(const QString &lineupid, const QString &type)
  • libs/libmythtv/sourceutil.cpp

     
    114114    return list;
    115115}
    116116
    117 bool SourceUtil::IsEncoder(uint sourceid)
     117bool SourceUtil::IsEncoder(uint sourceid, bool strict)
    118118{
    119119    bool encoder = true;
    120120
     
    135135        "WHERE sourceid = :SOURCEID");
    136136    query.bindValue(":SOURCEID", sourceid);
    137137
     138    bool has_any_chan = false;
    138139    if (!query.exec() || !query.isActive())
    139140        MythContext::DBError("SourceUtil::IsEncoder", query);
    140141    else
    141142    {
    142143        while (query.next())
     144        {
    143145            encoder &= !query.value(0).toInt() && !query.value(1).toInt();
     146            has_any_chan = true;
     147        }
    144148    }
    145149
    146     return encoder;
     150    return (strict && !has_any_chan) ? false: encoder;
    147151}
    148152
    149153bool SourceUtil::IsUnscanable(uint sourceid)
  • programs/mythfilldatabase/filldata.cpp

     
    3636
    3737    bool insert_channels = chan_data.insert_chan(source.id);
    3838    int new_channels = DataDirectProcessor::UpdateChannelsSafe(
    39         source.id, insert_channels);
     39        source.id, insert_channels, chan_data.filter_new_channels);
    4040
    4141    //  User must pass "--do-channel-updates" for these updates
    4242    if (chan_data.channel_updates)
    43         DataDirectProcessor::UpdateChannelsUnsafe(source.id);
     43    {
     44        DataDirectProcessor::UpdateChannelsUnsafe(
     45            source.id, chan_data.filter_new_channels);
     46    }
    4447    // TODO delete any channels which no longer exist in listings source
    4548
    4649    if (update_icons)
  • programs/mythfilldatabase/main.cpp

     
    156156        {
    157157            fill_data.chan_data.remove_new_channels = true;
    158158        }
     159        else if (!strcmp(a.argv()[argpos], "--do-not-filter-new-channels"))
     160        {
     161            fill_data.chan_data.filter_new_channels = false;
     162        }
    159163        else if (!strcmp(a.argv()[argpos], "--graboptions"))
    160164        {
    161165            if (((argpos + 1) >= a.argc()))
     
    388392            cout << "   option.  New channels are automatically removed\n";
    389393            cout << "   for DVB and HDTV sources that use DataDirect.\n";
    390394            cout << "\n";
     395            cout << "--do-not-filter-new-channels\n";
     396            cout << "   Normally MythTV tries to avoid adding ATSC channels\n";
     397            cout << "   to NTSC channel lineups. This option restores the\n";
     398            cout << "   behaviour of adding every channel in the downloaded\n";
     399            cout << "   channel lineup to MythTV's lineup, in case MythTV's\n";
     400            cout << "   smarts fail you.\n";
     401            cout << "\n";
    391402            cout << "--graboptions <\"options\">\n";
    392403            cout << "   Pass options to grabber. Do NOT use unless you know\n";
    393404            cout << "   what you are doing. Mythfilldatabase will\n";
  • programs/mythfilldatabase/channeldata.h

     
    3737    ChannelData() :
    3838        interactive(false),         non_us_updating(false),
    3939        channel_preset(false),      channel_updates(false),
    40         remove_new_channels(false), cardtype(QString::null) {}
     40        remove_new_channels(false), filter_new_channels(true),
     41        cardtype(QString::null) {}
    4142
    4243    bool insert_chan(uint sourceid);
    4344    void handleChannels(int id, QValueList<ChanInfo> *chanlist);
     
    5051    bool    channel_preset;
    5152    bool    channel_updates;
    5253    bool    remove_new_channels;
     54    bool    filter_new_channels;
    5355    QString cardtype;
    5456};
    5557