=== programs/mythfilldatabase/filldata.cpp Index: programs/mythfilldatabase/filldata.cpp =================================================================== --- programs/mythfilldatabase/filldata.cpp.orig 2006-06-20 17:32:57.000000000 -0400 +++ programs/mythfilldatabase/filldata.cpp 2006-06-20 17:36:06.000000000 -0400 @@ -60,7 +60,8 @@ bool dddataretrieved = false; bool mark_repeats = true; bool channel_updates = false; - +bool add_missing_channels = false; +bool ignore_on_air = false; int maxDays = 0; int listing_wrap_offset = 0; @@ -263,8 +264,12 @@ void clearDataBySource(int sourceid, QDateTime from, QDateTime to) { MSqlQuery query(MSqlQuery::InitCon()); - query.prepare("SELECT chanid FROM channel WHERE " - "sourceid = :SOURCE ;"); + QString queryStr = QString( + "SELECT chanid FROM channel WHERE " + "sourceid = :SOURCE"); + if (ignore_on_air) + queryStr += QString(" AND useonairguide <> 1"); + query.prepare(queryStr); query.bindValue(":SOURCE", sourceid); if (!query.exec()) @@ -795,6 +800,17 @@ ddprocessor.updateStationViewTable(); + if (ignore_on_air) + { + // Remove xmltvid from all channels with 'useonairguide' set + MSqlQuery remove_id(MSqlQuery::DDCon()); + remove_id.prepare( + "UPDATE channel SET xmltvid=NULL WHERE useonairguide = 1 " + "AND sourceid = :SOURCEID"); + remove_id.bindValue(":SOURCEID", source.id); + if (!remove_id.exec()) + MythContext::DBError("Removing xmltvid", remove_id); + } // Find all the channels in the dd_v_station temp table // where there is no channel with the same xmltvid in the // DB using the same source. @@ -840,9 +856,13 @@ } // First check if channel already in DB, but without xmltvid - query.prepare("SELECT chanid FROM channel " + QString queryStr = QString( + "SELECT chanid FROM channel " "WHERE sourceid = :SOURCEID AND " " (channum=:CHANNUM OR atscsrcid=:ATSCSRCID)"); + if (ignore_on_air) + queryStr += QString(" AND useonairguide <> 1"); + query.prepare(queryStr); query.bindValue(":SOURCEID", source.id); query.bindValue(":CHANNUM", channum); query.bindValue(":ATSCSRCID", atscsrcid); @@ -862,7 +882,7 @@ "UPDATE channel " "SET xmltvid = :XMLTVID " "WHERE chanid = :CHANID AND sourceid = :SOURCEID"); - + while (query.next()) { uint chanid = query.value(0).toInt(); @@ -879,36 +899,39 @@ continue; // go on to next channel without xmltv } - // The channel doesn't exist in the DB, insert it... - int mplexid = -1, majorC, minorC, chanid = 0; - long long freq; - get_atsc_stuff(channum, source.id, freqid, - majorC, minorC, freq); - - if (minorC > 0 && freq >= 0) + if (add_missing_channels) { - mplexid = ChannelUtil::CreateMultiplex( - source.id, "atsc", freq, "8vsb"); - } - - if ((mplexid > 0) || (minorC == 0)) - chanid = ChannelUtil::CreateChanID(source.id, channum); - - if (chanid > 0) - { - QString icon = ""; - int serviceid = 0; - bool oag = false; // use on air guide - bool hidden = false; - bool hidden_in_guide = false; - - ChannelUtil::CreateChannel( - mplexid, source.id, chanid, - callsign, name, channum, - serviceid, majorC, minorC, - oag, hidden, hidden_in_guide, - freqid, icon, tvformat, - xmltvid); + // The channel doesn't exist in the DB, insert it... + int mplexid = -1, majorC, minorC, chanid = 0; + long long freq; + get_atsc_stuff(channum, source.id, freqid, + majorC, minorC, freq); + + if (minorC > 0 && freq >= 0) + { + mplexid = ChannelUtil::CreateMultiplex( + source.id, "atsc", freq, "8vsb"); + } + + if ((mplexid > 0) || (minorC == 0)) + chanid = ChannelUtil::CreateChanID(source.id, channum); + + if (chanid > 0) + { + QString icon = ""; + int serviceid = 0; + bool oag = false; // use on air guide + bool hidden = false; + bool hidden_in_guide = false; + + ChannelUtil::CreateChannel( + mplexid, source.id, chanid, + callsign, name, channum, + serviceid, majorC, minorC, + oag, hidden, hidden_in_guide, + freqid, icon, tvformat, + xmltvid); + } } } } @@ -3441,6 +3464,14 @@ { channel_updates = true; } + else if (!strcmp(a.argv()[argpos], "--add_missing_channels")) + { + add_missing_channels = true; + } + else if (!strcmp(a.argv()[argpos], "--ignore_eit_channels")) + { + ignore_on_air = true; + } else if (!strcmp(a.argv()[argpos], "--graboptions")) { if (((argpos + 1) >= a.argc())) @@ -3646,6 +3677,14 @@ cout << " override custom channel names, which is why it is\n"; cout << " off by default.\n"; cout << "\n"; + cout << "--add_missing_channels\n"; + cout << " Insert any channels that are found but not in\n"; + cout << " the database. This is off by default, as it can\n"; + cout << " cause issues with DVB channels.\n"; + cout << "\n"; + cout << "--ignore_eit_channels\n"; + cout << " Don't get data for any channels that are marked\n"; cout << " As using the on-air guid.\n"; + cout << "\n"; cout << "--graboptions <\"options\">\n"; cout << " Pass options to grabber\n"; cout << "\n";