Ticket #3842: 3842-multilineup-head-v1.patch
File 3842-multilineup-head-v1.patch, 11.9 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/datadirect.h
324 324 static void UpdateProgramViewTable(uint sourceid); 325 325 326 326 // 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); 329 331 static void DataDirectProgramUpdate(void); 330 332 331 333 // static command, makes Labs and Schedules Direct ProgramIDs compatible. -
libs/libmythtv/sourceutil.h
16 16 static bool GetListingsLoginData(uint sourceid, 17 17 QString &grabber, QString &userid, 18 18 QString &passwd, QString &lineupid); 19 static bool IsEncoder(uint sourceid );19 static bool IsEncoder(uint sourceid, bool strict = false); 20 20 static bool IsUnscanable(uint sourceid); 21 21 static bool IsAnySourceScanable(void); 22 22 static bool UpdateChannelsFromListings( -
libs/libmythtv/datadirect.cpp
43 43 static QString process_dd_station(uint sourceid, 44 44 QString chan_major, QString chan_minor, 45 45 QString &tvformat, uint &freqid); 46 static voidupdate_channel_basic(uint sourceid, bool insert,46 static uint update_channel_basic(uint sourceid, bool insert, 47 47 QString xmltvid, QString callsign, 48 48 QString name, uint freqid, 49 49 QString chan_major, QString chan_minor); … … 679 679 MythContext::DBError("Analyzing table dd_productioncrew", query); 680 680 } 681 681 682 int DataDirectProcessor::UpdateChannelsSafe(uint sourceid, 683 bool insert_channels) 682 int DataDirectProcessor::UpdateChannelsSafe( 683 uint sourceid, 684 bool insert_channels, 685 bool filter_new_channels) 684 686 { 685 687 int new_channels = 0; 686 688 … … 704 706 return -1; 705 707 } 706 708 709 bool is_encoder = SourceUtil::IsEncoder(sourceid, true); 710 707 711 while (query.next()) 708 712 { 709 713 QString xmltvid = query.value(0).toString(); … … 713 717 QString chan_major = query.value(4).toString(); 714 718 QString chan_minor = query.value(5).toString(); 715 719 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 } 719 729 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) 721 736 { 722 VERBOSE(VB_GENERAL, LOC + QString("Not adding channel %1(%2).")737 VERBOSE(VB_GENERAL, LOC + QString("Not adding channel '%1' (%2).") 723 738 .arg(name).arg(callsign)); 724 739 } 725 740 new_channels++; … … 728 743 return new_channels; 729 744 } 730 745 731 bool DataDirectProcessor::UpdateChannelsUnsafe(uint sourceid) 746 bool DataDirectProcessor::UpdateChannelsUnsafe( 747 uint sourceid, bool filter_new_channels) 732 748 { 733 749 MSqlQuery dd_station_info(MSqlQuery::DDCon()); 734 750 dd_station_info.prepare( … … 750 766 " atsc_minor_chan = :MINORCHAN " 751 767 "WHERE xmltvid = :STATIONID AND sourceid = :SOURCEID"); 752 768 769 bool is_encoder = SourceUtil::IsEncoder(sourceid, true); 770 753 771 while (dd_station_info.next()) 754 772 { 755 773 uint freqid = dd_station_info.value(3).toUInt(); … … 759 777 QString channum = process_dd_station( 760 778 sourceid, chan_major, chan_minor, tvformat, freqid); 761 779 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 762 792 chan_update_q.bindValue(":CALLSIGN", dd_station_info.value(0)); 763 793 chan_update_q.bindValue(":NAME", dd_station_info.value(1)); 764 794 chan_update_q.bindValue(":STATIONID", dd_station_info.value(2)); … … 2091 2121 return channum; 2092 2122 } 2093 2123 2094 static voidupdate_channel_basic(uint sourceid, bool insert,2124 static uint update_channel_basic(uint sourceid, bool insert, 2095 2125 QString xmltvid, QString callsign, 2096 2126 QString name, uint freqid, 2097 2127 QString chan_major, QString chan_minor) … … 2124 2154 { 2125 2155 MythContext::DBError( 2126 2156 "Getting chanid of existing channel", query); 2127 return ; // go on to next channel without xmltv2157 return 0; // go on to next channel without xmltv 2128 2158 } 2129 2159 2130 2160 if (query.next()) … … 2137 2167 "SET xmltvid = :XMLTVID, name = :NAME, callsign = :CALLSIGN " 2138 2168 "WHERE chanid = :CHANID AND sourceid = :SOURCEID"); 2139 2169 2170 uint i = 0; 2140 2171 do 2141 2172 { 2142 2173 uint chanid = query.value(0).toInt(); … … 2156 2187 chan_update_q.bindValue(":XMLTVID", xmltvid); 2157 2188 chan_update_q.bindValue(":SOURCEID", sourceid); 2158 2189 2190 VERBOSE(VB_GENERAL, LOC + 2191 QString("Updating channel %1: '%2' (%3).") 2192 .arg(chanid).arg(name).arg(callsign)); 2193 2159 2194 if (!chan_update_q.exec() || !chan_update_q.isActive()) 2160 2195 { 2161 2196 MythContext::DBError( 2162 2197 "Updating XMLTVID of existing channel", chan_update_q); 2163 2198 continue; // go on to next instance of this channel 2164 2199 } 2200 i++; 2165 2201 } 2166 2202 while (query.next()); 2167 2203 2168 return ; // go on to next channel without xmltv2204 return i; // go on to next channel without xmltv 2169 2205 } 2170 2206 2171 2207 if (!insert) 2172 return ; // go on to next channel without xmltv2208 return 0; // go on to next channel without xmltv 2173 2209 2174 2210 // The channel doesn't exist in the DB, insert it... 2175 2211 int mplexid = -1, majorC, minorC, chanid = 0; … … 2183 2219 if ((mplexid > 0) || (minorC == 0)) 2184 2220 chanid = ChannelUtil::CreateChanID(sourceid, channum); 2185 2221 2222 VERBOSE(VB_GENERAL, LOC + QString("Adding channel %1 '%2' (%3).") 2223 .arg(channum).arg(name).arg(callsign)); 2224 2186 2225 if (chanid > 0) 2187 2226 { 2188 2227 QString icon = ""; … … 2200 2239 freq_id, icon, tvformat, 2201 2240 xmltvid); 2202 2241 } 2242 2243 return 1; 2203 2244 } 2204 2245 2205 2246 static void set_lineup_type(const QString &lineupid, const QString &type) -
libs/libmythtv/sourceutil.cpp
114 114 return list; 115 115 } 116 116 117 bool SourceUtil::IsEncoder(uint sourceid )117 bool SourceUtil::IsEncoder(uint sourceid, bool strict) 118 118 { 119 119 bool encoder = true; 120 120 … … 135 135 "WHERE sourceid = :SOURCEID"); 136 136 query.bindValue(":SOURCEID", sourceid); 137 137 138 bool has_any_chan = false; 138 139 if (!query.exec() || !query.isActive()) 139 140 MythContext::DBError("SourceUtil::IsEncoder", query); 140 141 else 141 142 { 142 143 while (query.next()) 144 { 143 145 encoder &= !query.value(0).toInt() && !query.value(1).toInt(); 146 has_any_chan = true; 147 } 144 148 } 145 149 146 return encoder;150 return (strict && !has_any_chan) ? false: encoder; 147 151 } 148 152 149 153 bool SourceUtil::IsUnscanable(uint sourceid) -
programs/mythfilldatabase/filldata.cpp
36 36 37 37 bool insert_channels = chan_data.insert_chan(source.id); 38 38 int new_channels = DataDirectProcessor::UpdateChannelsSafe( 39 source.id, insert_channels );39 source.id, insert_channels, chan_data.filter_new_channels); 40 40 41 41 // User must pass "--do-channel-updates" for these updates 42 42 if (chan_data.channel_updates) 43 DataDirectProcessor::UpdateChannelsUnsafe(source.id); 43 { 44 DataDirectProcessor::UpdateChannelsUnsafe( 45 source.id, chan_data.filter_new_channels); 46 } 44 47 // TODO delete any channels which no longer exist in listings source 45 48 46 49 if (update_icons) -
programs/mythfilldatabase/main.cpp
156 156 { 157 157 fill_data.chan_data.remove_new_channels = true; 158 158 } 159 else if (!strcmp(a.argv()[argpos], "--do-not-filter-new-channels")) 160 { 161 fill_data.chan_data.filter_new_channels = false; 162 } 159 163 else if (!strcmp(a.argv()[argpos], "--graboptions")) 160 164 { 161 165 if (((argpos + 1) >= a.argc())) … … 388 392 cout << " option. New channels are automatically removed\n"; 389 393 cout << " for DVB and HDTV sources that use DataDirect.\n"; 390 394 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"; 391 402 cout << "--graboptions <\"options\">\n"; 392 403 cout << " Pass options to grabber. Do NOT use unless you know\n"; 393 404 cout << " what you are doing. Mythfilldatabase will\n"; -
programs/mythfilldatabase/channeldata.h
37 37 ChannelData() : 38 38 interactive(false), non_us_updating(false), 39 39 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) {} 41 42 42 43 bool insert_chan(uint sourceid); 43 44 void handleChannels(int id, QValueList<ChanInfo> *chanlist); … … 50 51 bool channel_preset; 51 52 bool channel_updates; 52 53 bool remove_new_channels; 54 bool filter_new_channels; 53 55 QString cardtype; 54 56 }; 55 57