Ticket #1435: data-direct.diff
File data-direct.diff, 6.6 KB (added by , 18 years ago) |
---|
-
programs/mythfilldatabase/filldata.cpp
=== programs/mythfilldatabase/filldata.cpp
old new 60 60 bool dddataretrieved = false; 61 61 bool mark_repeats = true; 62 62 bool channel_updates = false; 63 63 bool add_missing_channels = true; 64 bool ignore_on_air = false; 64 65 int maxDays = 0; 65 66 int listing_wrap_offset = 0; 66 67 … … 263 264 void clearDataBySource(int sourceid, QDateTime from, QDateTime to) 264 265 { 265 266 MSqlQuery query(MSqlQuery::InitCon()); 266 query.prepare("SELECT chanid FROM channel WHERE " 267 "sourceid = :SOURCE ;"); 267 QString queryStr = QString( 268 "SELECT chanid FROM channel WHERE " 269 "sourceid = :SOURCE"); 270 if (ignore_on_air) 271 queryStr += QString(" AND useonairguide <> 1"); 272 query.prepare(queryStr); 268 273 query.bindValue(":SOURCE", sourceid); 269 274 270 275 if (!query.exec()) … … 795 800 796 801 ddprocessor.updateStationViewTable(); 797 802 803 if (ignore_on_air) 804 { 805 // Remove xmltvid from all channels with 'useonairguide' set 806 MSqlQuery remove_id(MSqlQuery::DDCon()); 807 remove_id.prepare( 808 "UPDATE channel SET xmltvid=NULL WHERE useonairguide = 1 " 809 "AND sourceid = :SOURCEID"); 810 remove_id.bindValue(":SOURCEID", source.id); 811 if (!remove_id.exec()) 812 MythContext::DBError("Removing xmltvid", remove_id); 813 } 798 814 // Find all the channels in the dd_v_station temp table 799 815 // where there is no channel with the same xmltvid in the 800 816 // DB using the same source. … … 840 856 } 841 857 842 858 // First check if channel already in DB, but without xmltvid 843 query.prepare("SELECT chanid FROM channel " 859 QString queryStr = QString( 860 "SELECT chanid FROM channel " 844 861 "WHERE sourceid = :SOURCEID AND " 845 862 " (channum=:CHANNUM OR atscsrcid=:ATSCSRCID)"); 863 if (ignore_on_air) 864 queryStr += QString(" AND useonairguide <> 1"); 865 query.prepare(queryStr); 846 866 query.bindValue(":SOURCEID", source.id); 847 867 query.bindValue(":CHANNUM", channum); 848 868 query.bindValue(":ATSCSRCID", atscsrcid); … … 862 882 "UPDATE channel " 863 883 "SET xmltvid = :XMLTVID " 864 884 "WHERE chanid = :CHANID AND sourceid = :SOURCEID"); 865 885 866 886 while (query.next()) 867 887 { 868 888 uint chanid = query.value(0).toInt(); … … 879 899 continue; // go on to next channel without xmltv 880 900 } 881 901 882 // The channel doesn't exist in the DB, insert it... 883 int mplexid = -1, majorC, minorC, chanid = 0; 884 long long freq; 885 get_atsc_stuff(channum, source.id, freqid, 886 majorC, minorC, freq); 887 888 if (minorC > 0 && freq >= 0) 902 if (add_missing_channels) 889 903 { 890 mplexid = ChannelUtil::CreateMultiplex( 891 source.id, "atsc", freq, "8vsb"); 892 } 893 894 if ((mplexid > 0) || (minorC == 0)) 895 chanid = ChannelUtil::CreateChanID(source.id, channum); 896 897 if (chanid > 0) 898 { 899 QString icon = ""; 900 int serviceid = 0; 901 bool oag = false; // use on air guide 902 bool hidden = false; 903 bool hidden_in_guide = false; 904 905 ChannelUtil::CreateChannel( 906 mplexid, source.id, chanid, 907 callsign, name, channum, 908 serviceid, majorC, minorC, 909 oag, hidden, hidden_in_guide, 910 freqid, icon, tvformat, 911 xmltvid); 904 // The channel doesn't exist in the DB, insert it... 905 int mplexid = -1, majorC, minorC, chanid = 0; 906 long long freq; 907 get_atsc_stuff(channum, source.id, freqid, 908 majorC, minorC, freq); 909 910 if (minorC > 0 && freq >= 0) 911 { 912 mplexid = ChannelUtil::CreateMultiplex( 913 source.id, "atsc", freq, "8vsb"); 914 } 915 916 if ((mplexid > 0) || (minorC == 0)) 917 chanid = ChannelUtil::CreateChanID(source.id, channum); 918 919 if (chanid > 0) 920 { 921 QString icon = ""; 922 int serviceid = 0; 923 bool oag = false; // use on air guide 924 bool hidden = false; 925 bool hidden_in_guide = false; 926 927 ChannelUtil::CreateChannel( 928 mplexid, source.id, chanid, 929 callsign, name, channum, 930 serviceid, majorC, minorC, 931 oag, hidden, hidden_in_guide, 932 freqid, icon, tvformat, 933 xmltvid); 934 } 912 935 } 913 936 } 914 937 } … … 3440 3463 { 3441 3464 channel_updates = true; 3442 3465 } 3466 else if (!strcmp(a.argv()[argpos], "--dont_add_missing_channels")) 3467 { 3468 add_missing_channels = false; 3469 } 3470 else if (!strcmp(a.argv()[argpos], "--ignore_eit_channels")) 3471 { 3472 ignore_on_air = true; 3473 } 3443 3474 else if (!strcmp(a.argv()[argpos], "--graboptions")) 3444 3475 { 3445 3476 if (((argpos + 1) >= a.argc())) … … 3645 3676 cout << " override custom channel names, which is why it is\n"; 3646 3677 cout << " off by default.\n"; 3647 3678 cout << "\n"; 3679 cout << "--dont_add_missing_channels\n"; 3680 cout << " Don't insert any channels that are found by\n"; 3681 cout << " mythfilldatabase but are not in the database. This\n"; 3682 cout << " is useful for DVB channels.\n"; 3683 cout << "\n"; 3684 cout << "--ignore_eit_channels\n"; 3685 cout << " Don't get data for any channels that are marked\n"; cout << " As using the on-air guid.\n"; 3686 cout << "\n"; 3648 3687 cout << "--graboptions <\"options\">\n"; 3649 3688 cout << " Pass options to grabber\n"; 3650 3689 cout << "\n";