MythTV  master
mythfilldatabase.cpp
Go to the documentation of this file.
1 // C headers
2 #include <unistd.h>
3 
4 // C++ headers
5 #include <iostream>
6 
7 // Qt headers
8 #include <QtGlobal>
9 #include <QCoreApplication>
10 #include <QFileInfo>
11 
12 // MythTV headers
13 #include "libmyth/mythcontext.h"
15 #include "libmythbase/exitcodes.h"
16 #include "libmythbase/mythconfig.h"
17 #include "libmythbase/mythdate.h"
18 #include "libmythbase/mythdb.h"
22 #include "libmythbase/mythversion.h"
23 #include "libmythbase/remoteutil.h"
25 #include "libmythtv/dbcheck.h"
28 #include "libmythtv/videosource.h" // for is_grabber..
29 
30 // filldata headers
31 #include "filldata.h"
33 
34 namespace
35 {
36  void cleanup()
37  {
38  delete gContext;
39  gContext = nullptr;
41  }
42 }
43 
44 int main(int argc, char *argv[])
45 {
46  FillData fill_data;
47  int fromfile_id = 1;
48  QString fromfile_name;
49  bool from_file = false;
50  bool mark_repeats = true;
51 
52  int sourceid = -1;
53 
55  if (!cmdline.Parse(argc, argv))
56  {
59  }
60 
61  if (cmdline.toBool("showhelp"))
62  {
64  return GENERIC_EXIT_OK;
65  }
66 
67  if (cmdline.toBool("showversion"))
68  {
70  return GENERIC_EXIT_OK;
71  }
72 
73  QCoreApplication a(argc, argv);
74  QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFILLDATABASE);
75 
76  myth_nice(19);
77 
78  int retval = cmdline.ConfigureLogging();
79  if (retval != GENERIC_EXIT_OK)
80  return retval;
81 
82  if (cmdline.toBool("ddgraball"))
83  LOG(VB_GENERAL, LOG_WARNING,
84  "Invalid option, see: mythfilldatabase --help dd-grab-all");
85 
86  if (cmdline.toBool("manual"))
87  {
88  std::cout << "###\n";
89  std::cout << "### Running in manual channel configuration mode.\n";
90  std::cout << "### This will ask you questions about every channel.\n";
91  std::cout << "###\n";
92  fill_data.m_chanData.m_interactive = true;
93  }
94 
95  if (cmdline.toBool("onlyguide") || cmdline.toBool("update"))
96  {
97  LOG(VB_GENERAL, LOG_NOTICE,
98  "Only updating guide data, channel and icon updates will be ignored");
99  fill_data.m_chanData.m_guideDataOnly = true;
100  }
101 
102  if (cmdline.toBool("preset"))
103  {
104  std::cout << "###\n";
105  std::cout << "### Running in preset channel configuration mode.\n";
106  std::cout << "### This will assign channel ";
107  std::cout << "preset numbers to every channel.\n";
108  std::cout << "###\n";
109  fill_data.m_chanData.m_channelPreset = true;
110  }
111 
112  if (cmdline.toBool("file"))
113  {
114  // manual file mode
115  if (!cmdline.toBool("sourceid") ||
116  !cmdline.toBool("xmlfile"))
117  {
118  std::cerr << "The --file option must be used in combination" << std::endl
119  << "with both --sourceid and --xmlfile." << std::endl;
121  }
122 
123  fromfile_id = cmdline.toInt("sourceid");
124  fromfile_name = cmdline.toString("xmlfile");
125 
126  LOG(VB_GENERAL, LOG_INFO,
127  "Bypassing grabbers, reading directly from file");
128  from_file = true;
129  }
130 
131  if (cmdline.toBool("dochannelupdates"))
132  fill_data.m_chanData.m_channelUpdates = true;
133  if (cmdline.toBool("nofilterchannels"))
134  fill_data.m_chanData.m_filterNewChannels = false;
135  if (!cmdline.GetPassthrough().isEmpty())
136  fill_data.m_grabOptions = " " + cmdline.GetPassthrough();
137  if (cmdline.toBool("sourceid"))
138  sourceid = cmdline.toInt("sourceid");
139  if (cmdline.toBool("cardtype"))
140  {
141  if (!cmdline.toBool("sourceid"))
142  {
143  std::cerr << "The --cardtype option must be used in combination" << std::endl
144  << "with a --sourceid option." << std::endl;
146  }
147 
148  fill_data.m_chanData.m_cardType = cmdline.toString("cardtype")
149  .trimmed().toUpper();
150  }
151  if (cmdline.toBool("maxdays") && cmdline.toInt("maxdays") > 0)
152  {
153  fill_data.m_maxDays = cmdline.toInt("maxdays");
154  if (fill_data.m_maxDays == 1)
155  fill_data.SetRefresh(0, true);
156  }
157 
158  if (cmdline.toBool("refreshtoday"))
159  cmdline.SetValue("refresh",
160  cmdline.toStringList("refresh") << "today");
161  if (cmdline.toBool("dontrefreshtomorrow"))
162  cmdline.SetValue("refresh",
163  cmdline.toStringList("refresh") << "nottomorrow");
164  if (cmdline.toBool("refreshsecond"))
165  cmdline.SetValue("refresh",
166  cmdline.toStringList("refresh") << "second");
167  if (cmdline.toBool("refreshall"))
168  cmdline.SetValue("refresh",
169  cmdline.toStringList("refresh") << "all");
170  if (cmdline.toBool("refreshday"))
171  {
172  cmdline.SetValue("refresh",
173  cmdline.toStringList("refresh") <<
174  cmdline.toStringList("refreshday"));
175  }
176 
177  QStringList sl = cmdline.toStringList("refresh");
178  if (!sl.isEmpty())
179  {
180  for (const auto & item : qAsConst(sl))
181  {
182  QString warn = QString("Invalid entry in --refresh list: %1")
183  .arg(item);
184 
185  bool enable = !item.contains("not");
186 
187  if (item.contains("today"))
188  fill_data.SetRefresh(0, enable);
189  else if (item.contains("tomorrow"))
190  fill_data.SetRefresh(1, enable);
191  else if (item.contains("second"))
192  fill_data.SetRefresh(2, enable);
193  else if (item.contains("all"))
194  fill_data.SetRefresh(FillData::kRefreshAll, enable);
195  else if (item.contains("-"))
196  {
197  bool ok = false;
198  QStringList r = item.split("-");
199 
200  uint lower = r[0].toUInt(&ok);
201  if (!ok)
202  {
203  std::cerr << warn.toLocal8Bit().constData() << std::endl;
204  return 0;
205  }
206 
207  uint upper = r[1].toUInt(&ok);
208  if (!ok)
209  {
210  std::cerr << warn.toLocal8Bit().constData() << std::endl;
211  return 0;
212  }
213 
214  if (lower > upper)
215  {
216  std::cerr << warn.toLocal8Bit().constData() << std::endl;
217  return 0;
218  }
219 
220  for (uint j = lower; j <= upper; ++j)
221  fill_data.SetRefresh(j, true);
222  }
223  else
224  {
225  bool ok = false;
226  uint day = item.toUInt(&ok);
227  if (!ok)
228  {
229  std::cerr << warn.toLocal8Bit().constData() << std::endl;
230  return 0;
231  }
232 
233  fill_data.SetRefresh(day, true);
234  }
235  }
236  }
237 
238  if (cmdline.toBool("dontrefreshtba"))
239  fill_data.m_refreshTba = false;
240  if (cmdline.toBool("onlychannels"))
241  fill_data.m_onlyUpdateChannels = true;
242  if (cmdline.toBool("noallatonce"))
243  fill_data.m_noAllAtOnce = true;
244 
245  mark_repeats = cmdline.toBool("markrepeats");
246 
247  CleanupGuard callCleanup(cleanup);
248 
249 #ifndef _WIN32
251 #endif
252 
253  gContext = new MythContext(MYTH_BINARY_VERSION);
254  if (!gContext->Init(false))
255  {
256  LOG(VB_GENERAL, LOG_ERR, "Failed to init MythContext, exiting.");
258  }
259 
260  setHttpProxy();
261 
262  MythTranslation::load("mythfrontend");
263 
264  if (!UpgradeTVDatabaseSchema(false))
265  {
266  LOG(VB_GENERAL, LOG_ERR, "Incorrect database schema");
268  }
269 
270  if (gCoreContext->SafeConnectToMasterServer(true, false))
271  {
272  LOG(VB_GENERAL, LOG_INFO,
273  "Opening blocking connection to master backend");
274  }
275  else
276  {
277  LOG(VB_GENERAL, LOG_WARNING,
278  "Failed to connect to master backend. MythFillDatabase will "
279  "continue running but will be unable to prevent backend from "
280  "shutting down, or triggering a reschedule when complete.");
281  }
282 
283  if (from_file)
284  {
285  QString status = QObject::tr("currently running.");
286  QDateTime GuideDataBefore;
287  QDateTime GuideDataAfter;
288 
290  updateLastRunStatus(status);
291 
292  MSqlQuery query(MSqlQuery::InitCon());
293  query.prepare("SELECT MAX(endtime) FROM program p "
294  "LEFT JOIN channel c ON p.chanid=c.chanid "
295  "WHERE c.deleted IS NULL AND c.sourceid= :SRCID "
296  "AND manualid = 0 AND c.xmltvid != '';");
297  query.bindValue(":SRCID", fromfile_id);
298 
299  if (query.exec() && query.next())
300  {
301  if (!query.isNull(0))
302  GuideDataBefore =
303  MythDate::fromString(query.value(0).toString());
304  }
305 
306  if (!fill_data.GrabDataFromFile(fromfile_id, fromfile_name))
307  {
308  return GENERIC_EXIT_NOT_OK;
309  }
310 
312 
313  query.prepare("SELECT MAX(endtime) FROM program p "
314  "LEFT JOIN channel c ON p.chanid=c.chanid "
315  "WHERE c.deleted IS NULL AND c.sourceid= :SRCID "
316  "AND manualid = 0 AND c.xmltvid != '';");
317  query.bindValue(":SRCID", fromfile_id);
318 
319  if (query.exec() && query.next())
320  {
321  if (!query.isNull(0))
322  GuideDataAfter =
323  MythDate::fromString(query.value(0).toString());
324  }
325 
326  if (GuideDataAfter == GuideDataBefore)
327  {
328  status = QObject::tr("mythfilldatabase ran, but did not insert "
329  "any new data into the Guide. This can indicate a "
330  "potential problem with the XML file used for the update.");
331  }
332  else
333  {
334  status = QObject::tr("Successful.");
335  }
336 
337  updateLastRunStatus(status);
338  }
339  else
340  {
341  DataSourceList sourcelist;
342 
343  MSqlQuery sourcequery(MSqlQuery::InitCon());
344  QString where;
345 
346  if (sourceid != -1)
347  {
348  LOG(VB_GENERAL, LOG_INFO,
349  QString("Running for sourceid %1 ONLY because --sourceid "
350  "was given on command-line").arg(sourceid));
351  where = QString("WHERE sourceid = %1").arg(sourceid);
352  }
353 
354  QString querystr = QString("SELECT sourceid,name,xmltvgrabber,userid,"
355  "password,lineupid "
356  "FROM videosource ") + where +
357  QString(" ORDER BY sourceid;");
358 
359  if (sourcequery.exec(querystr))
360  {
361  if (sourcequery.size() > 0)
362  {
363  while (sourcequery.next())
364  {
365  DataSource newsource;
366 
367  newsource.id = sourcequery.value(0).toInt();
368  newsource.name = sourcequery.value(1).toString();
369  newsource.xmltvgrabber = sourcequery.value(2).toString();
370  newsource.userid = sourcequery.value(3).toString();
371  newsource.password = sourcequery.value(4).toString();
372  newsource.lineupid = sourcequery.value(5).toString();
373 
374  newsource.xmltvgrabber_baseline = false;
375  newsource.xmltvgrabber_manualconfig = false;
376  newsource.xmltvgrabber_cache = false;
377  newsource.xmltvgrabber_prefmethod = "";
378 
379  sourcelist.push_back(newsource);
380  }
381  }
382  else
383  {
384  LOG(VB_GENERAL, LOG_ERR,
385  "There are no channel sources defined, did you run "
386  "the setup program?");
388  }
389  }
390  else
391  {
392  MythDB::DBError("loading channel sources", sourcequery);
393  return GENERIC_EXIT_DB_ERROR;
394  }
395 
396  if (!fill_data.Run(sourcelist))
397  LOG(VB_GENERAL, LOG_ERR, "Failed to fetch some program info");
398  else
399  LOG(VB_GENERAL, LOG_NOTICE, "Data fetching complete.");
400  }
401 
402  if (fill_data.m_onlyUpdateChannels && !fill_data.m_needPostGrabProc)
403  {
404  return GENERIC_EXIT_OK;
405  }
406 
407  LOG(VB_GENERAL, LOG_INFO, "Adjusting program database end times.");
408  int update_count = ProgramData::fix_end_times();
409  if (update_count == -1)
410  LOG(VB_GENERAL, LOG_ERR, "fix_end_times failed!");
411  else
412  LOG(VB_GENERAL, LOG_INFO,
413  QString(" %1 replacements made").arg(update_count));
414 
415  LOG(VB_GENERAL, LOG_INFO, "Marking generic episodes.");
416 
417  MSqlQuery query(MSqlQuery::InitCon());
418  query.prepare("UPDATE program SET generic = 1 WHERE "
419  "((programid = '' AND subtitle = '' AND description = '') OR "
420  " (programid <> '' AND category_type = 'series' AND "
421  " program.programid LIKE '%0000'));");
422 
423  if (!query.exec())
424  MythDB::DBError("mark generic", query);
425  else
426  LOG(VB_GENERAL, LOG_INFO,
427  QString(" Found %1").arg(query.numRowsAffected()));
428 
429  LOG(VB_GENERAL, LOG_INFO, "Extending non-unique programids "
430  "with multiple parts.");
431 
432  int found = 0;
434  sel.prepare("SELECT DISTINCT programid, partnumber, parttotal "
435  "FROM program WHERE partnumber > 0 AND parttotal > 0 AND "
436  "programid LIKE '%0000'");
437  if (sel.exec())
438  {
440  repl.prepare("UPDATE program SET programid = :NEWID "
441  "WHERE programid = :OLDID AND "
442  "partnumber = :PARTNUM AND "
443  "parttotal = :PARTTOTAL");
444 
445  while (sel.next())
446  {
447  QString orig_programid = sel.value(0).toString();
448  QString new_programid = orig_programid.left(10);
449  QString part;
450 
451  int partnum = sel.value(1).toInt();
452  int parttotal = sel.value(2).toInt();
453 
454  part.setNum(parttotal);
455  new_programid.append(part.rightJustified(2, '0'));
456  part.setNum(partnum);
457  new_programid.append(part.rightJustified(2, '0'));
458 
459  LOG(VB_GENERAL, LOG_INFO,
460  QString(" %1 -> %2 (part %3 of %4)")
461  .arg(orig_programid, new_programid)
462  .arg(partnum).arg(parttotal));
463 
464  repl.bindValue(":NEWID", new_programid);
465  repl.bindValue(":OLDID", orig_programid);
466  repl.bindValue(":PARTNUM", partnum);
467  repl.bindValue(":PARTTOTAL", parttotal);
468  if (!repl.exec())
469  {
470  LOG(VB_GENERAL, LOG_INFO,
471  QString("Fudging programid from '%1' to '%2'")
472  .arg(orig_programid, new_programid));
473  }
474  else
475  found += repl.numRowsAffected();
476  }
477  }
478 
479  LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
480 
481  LOG(VB_GENERAL, LOG_INFO, "Fixing missing original airdates.");
482  query.prepare("UPDATE program p "
483  "JOIN ( "
484  " SELECT programid, MAX(originalairdate) maxoad "
485  " FROM program "
486  " WHERE programid <> '' AND "
487  " originalairdate IS NOT NULL "
488  " GROUP BY programid ) oad "
489  " ON p.programid = oad.programid "
490  "SET p.originalairdate = oad.maxoad "
491  "WHERE p.originalairdate IS NULL");
492 
493  if (query.exec())
494  {
495  LOG(VB_GENERAL, LOG_INFO,
496  QString(" Found %1 with programids")
497  .arg(query.numRowsAffected()));
498  }
499 
500  query.prepare("UPDATE program p "
501  "JOIN ( "
502  " SELECT title, subtitle, description, "
503  " MAX(originalairdate) maxoad "
504  " FROM program "
505  " WHERE programid = '' AND "
506  " originalairdate IS NOT NULL "
507  " GROUP BY title, subtitle, description ) oad "
508  " ON p.programid = '' AND "
509  " p.title = oad.title AND "
510  " p.subtitle = oad.subtitle AND "
511  " p.description = oad.description "
512  "SET p.originalairdate = oad.maxoad "
513  "WHERE p.originalairdate IS NULL");
514 
515  if (query.exec())
516  {
517  LOG(VB_GENERAL, LOG_INFO,
518  QString(" Found %1 without programids")
519  .arg(query.numRowsAffected()));
520  }
521 
522  if (mark_repeats)
523  {
524  LOG(VB_GENERAL, LOG_INFO, "Marking repeats.");
525 
526  int newEpiWindow = gCoreContext->GetNumSetting( "NewEpisodeWindow", 14);
527 
528  MSqlQuery query2(MSqlQuery::InitCon());
529  query2.prepare("UPDATE program SET previouslyshown = 1 "
530  "WHERE previouslyshown = 0 "
531  "AND originalairdate is not null "
532  "AND (to_days(starttime) - to_days(originalairdate)) "
533  " > :NEWWINDOW;");
534  query2.bindValue(":NEWWINDOW", newEpiWindow);
535 
536  if (query2.exec())
537  LOG(VB_GENERAL, LOG_INFO,
538  QString(" Found %1").arg(query2.numRowsAffected()));
539 
540  LOG(VB_GENERAL, LOG_INFO, "Unmarking new episode rebroadcast repeats.");
541  query2.prepare("UPDATE program SET previouslyshown = 0 "
542  "WHERE previouslyshown = 1 "
543  "AND originalairdate is not null "
544  "AND (to_days(starttime) - to_days(originalairdate)) "
545  " <= :NEWWINDOW;");
546  query2.bindValue(":NEWWINDOW", newEpiWindow);
547 
548  if (query2.exec())
549  LOG(VB_GENERAL, LOG_INFO,
550  QString(" Found %1").arg(query2.numRowsAffected()));
551  }
552 
553  // Mark first and last showings
555  updt.prepare("UPDATE program SET first = 0, last = 0;");
556  if (!updt.exec())
557  MythDB::DBError("Clearing first and last showings", updt);
558 
559  LOG(VB_GENERAL, LOG_INFO, "Marking episode first showings.");
560  updt.prepare("UPDATE program "
561  "JOIN (SELECT MIN(p.starttime) AS starttime, p.programid "
562  " FROM program p, channel c "
563  " WHERE p.programid <> '' "
564  " AND p.chanid = c.chanid "
565  " AND c.deleted IS NULL "
566  " AND c.visible > 0 "
567  " GROUP BY p.programid "
568  " ) AS firsts "
569  "ON program.programid = firsts.programid "
570  " AND program.starttime = firsts.starttime "
571  "SET program.first=1;");
572  if (!updt.exec())
573  MythDB::DBError("Marking first showings by id", updt);
574  found = updt.numRowsAffected();
575 
576  updt.prepare("UPDATE program "
577  "JOIN (SELECT MIN(p.starttime) AS starttime, p.title, p.subtitle, "
578  " LEFT(p.description, 1024) AS partdesc "
579  " FROM program p, channel c "
580  " WHERE p.programid = '' "
581  " AND p.chanid = c.chanid "
582  " AND c.deleted IS NULL "
583  " AND c.visible > 0 "
584  " GROUP BY p.title, p.subtitle, partdesc "
585  " ) AS firsts "
586  "ON program.starttime = firsts.starttime "
587  " AND program.title = firsts.title "
588  " AND program.subtitle = firsts.subtitle "
589  " AND LEFT(program.description, 1024) = firsts.partdesc "
590  "SET program.first = 1 "
591  "WHERE program.programid = '';");
592  if (!updt.exec())
593  MythDB::DBError("Marking first showings", updt);
594  found += updt.numRowsAffected();
595  LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
596 
597  LOG(VB_GENERAL, LOG_INFO, "Marking episode last showings.");
598  updt.prepare("UPDATE program "
599  "JOIN (SELECT MAX(p.starttime) AS starttime, p.programid "
600  " FROM program p, channel c "
601  " WHERE p.programid <> '' "
602  " AND p.chanid = c.chanid "
603  " AND c.deleted IS NULL "
604  " AND c.visible > 0 "
605  " GROUP BY p.programid "
606  " ) AS lasts "
607  "ON program.programid = lasts.programid "
608  " AND program.starttime = lasts.starttime "
609  "SET program.last=1;");
610  if (!updt.exec())
611  MythDB::DBError("Marking last showings by id", updt);
612  found = updt.numRowsAffected();
613 
614  updt.prepare("UPDATE program "
615  "JOIN (SELECT MAX(p.starttime) AS starttime, p.title, p.subtitle, "
616  " LEFT(p.description, 1024) AS partdesc "
617  " FROM program p, channel c "
618  " WHERE p.programid = '' "
619  " AND p.chanid = c.chanid "
620  " AND c.deleted IS NULL "
621  " AND c.visible > 0 "
622  " GROUP BY p.title, p.subtitle, partdesc "
623  " ) AS lasts "
624  "ON program.starttime = lasts.starttime "
625  " AND program.title = lasts.title "
626  " AND program.subtitle = lasts.subtitle "
627  " AND LEFT(program.description, 1024) = lasts.partdesc "
628  "SET program.last = 1 "
629  "WHERE program.programid = '';");
630  if (!updt.exec())
631  MythDB::DBError("Marking last showings", updt);
632  found += updt.numRowsAffected();
633  LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
634 
635 #if 1
636  // limit MSqlQuery's lifetime
637  MSqlQuery query2(MSqlQuery::InitCon());
638  query2.prepare("SELECT count(previouslyshown) "
639  "FROM program WHERE previouslyshown = 1;");
640  if (query2.exec() && query2.next())
641  {
642  if (query2.value(0).toInt() != 0)
643  gCoreContext->SaveSettingOnHost("HaveRepeats", "1", nullptr);
644  else
645  gCoreContext->SaveSettingOnHost("HaveRepeats", "0", nullptr);
646  }
647 #endif
648 
649  if (!cmdline.toBool("noresched"))
650  {
651  LOG(VB_GENERAL, LOG_INFO, "\n"
652  "===============================================================\n"
653  "| Attempting to contact the master backend for rescheduling. |\n"
654  "| If the master is not running, rescheduling will happen when |\n"
655  "| the master backend is restarted. |\n"
656  "===============================================================");
657 
658  ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(),
659  "MythFillDatabase");
660  }
661 
662  gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
663 
664  gCoreContext->SendSystemEvent("MYTHFILLDATABASE_RAN");
665 
666  LOG(VB_GENERAL, LOG_NOTICE, "mythfilldatabase run complete.");
667 
668  return GENERIC_EXIT_OK;
669 }
670 
671 /* vim: set expandtab tabstop=4 shiftwidth=4: */
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:807
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:128
MythCoreContext::SendMessage
void SendMessage(const QString &message)
Definition: mythcorecontext.cpp:1515
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:215
GENERIC_EXIT_SETUP_ERROR
@ GENERIC_EXIT_SETUP_ERROR
Incorrectly setup system.
Definition: exitcodes.h:22
setHttpProxy
void setHttpProxy(void)
Get network proxy settings from OS, and use for [Q]Http[Comms].
Definition: mythmiscutil.cpp:796
MSqlQuery::isNull
bool isNull(int field) const
Definition: mythdbcon.h:220
DataSource::xmltvgrabber
QString xmltvgrabber
Definition: filldata.h:29
mythdb.h
updateLastRunStart
bool updateLastRunStart(void)
Definition: filldata.cpp:45
UpgradeTVDatabaseSchema
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
Definition: dbcheck.cpp:361
cmdline
MythCommFlagCommandLineParser cmdline
Definition: mythcommflag.cpp:72
DataSourceList
std::vector< DataSource > DataSourceList
Definition: filldata.h:40
ChannelData::m_cardType
QString m_cardType
Definition: channeldata.h:33
DataSource::name
QString name
Definition: filldata.h:28
MythContext
Startup context for MythTV.
Definition: mythcontext.h:43
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:205
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:608
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
DataSource::lineupid
QString lineupid
Definition: filldata.h:32
mythsystemevent.h
filldata.h
DataSource
Definition: filldata.h:25
GENERIC_EXIT_OK
@ GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:11
remoteutil.h
MythCoreContext::SafeConnectToMasterServer
bool SafeConnectToMasterServer(bool blockingClient=true, bool openEventSocket=true)
Definition: mythcorecontext.cpp:344
MythCommandLineParser::Parse
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
Definition: mythcommandlineparser.cpp:1553
ChannelData::m_channelPreset
bool m_channelPreset
Definition: channeldata.h:30
mythdate.h
FillData::m_grabOptions
QString m_grabOptions
Definition: filldata.h:66
ChannelData::m_guideDataOnly
bool m_guideDataOnly
Definition: channeldata.h:29
ChannelData::m_interactive
bool m_interactive
Definition: channeldata.h:28
mythlogging.h
GENERIC_EXIT_NO_MYTHCONTEXT
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
Definition: exitcodes.h:14
ProgramData::fix_end_times
static int fix_end_times(void)
Definition: programdata.cpp:1646
updateLastRunEnd
bool updateLastRunEnd(void)
Definition: filldata.cpp:37
mythfilldatabase_commandlineparser.h
dbcheck.h
MythCoreContext::SendSystemEvent
void SendSystemEvent(const QString &msg)
Definition: mythcorecontext.cpp:1542
MythFillDatabaseCommandLineParser
Definition: mythfilldatabase_commandlineparser.h:6
signalhandling.h
ChannelData::m_channelUpdates
bool m_channelUpdates
Definition: channeldata.h:31
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:540
CleanupGuard
Definition: cleanupguard.h:6
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:227
FillData::Run
bool Run(DataSourceList &sourcelist)
Goes through the sourcelist and updates its channels with program info grabbed with the associated gr...
Definition: filldata.cpp:245
MythCommandLineParser::PrintVersion
static void PrintVersion(void)
Print application version information.
Definition: mythcommandlineparser.cpp:1381
mythtranslation.h
scheduledrecording.h
MythCommandLineParser::PrintHelp
void PrintHelp(void) const
Print command line option help.
Definition: mythcommandlineparser.cpp:1397
FillData::m_chanData
ChannelData m_chanData
Definition: filldata.h:63
GENERIC_EXIT_NOT_OK
@ GENERIC_EXIT_NOT_OK
Exited with error.
Definition: exitcodes.h:12
uint
unsigned int uint
Definition: compat.h:81
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:54
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:910
cleanup
static QString cleanup(const QString &str)
Definition: remoteencoder.cpp:673
MythDate::fromString
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:34
FillData::GrabDataFromFile
bool GrabDataFromFile(int id, const QString &filename)
Definition: filldata.cpp:87
SignalHandler::Init
static void Init(QObject *parent=nullptr)
Definition: signalhandling.cpp:127
DataSource::xmltvgrabber_prefmethod
QString xmltvgrabber_prefmethod
Definition: filldata.h:38
FillData
Definition: filldata.h:42
mythmiscutil.h
MYTH_APPNAME_MYTHFILLDATABASE
static constexpr const char * MYTH_APPNAME_MYTHFILLDATABASE
Definition: mythcorecontext.h:24
MythCommandLineParser::toString
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
Definition: mythcommandlineparser.cpp:2358
FillData::m_onlyUpdateChannels
bool m_onlyUpdateChannels
Definition: filldata.h:73
MythCommandLineParser::SetValue
bool SetValue(const QString &key, const QVariant &value)
Set a new stored value for an existing argument definition, or spawn a new definition store value in.
Definition: mythcommandlineparser.cpp:2829
MythCommandLineParser::toBool
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
Definition: mythcommandlineparser.cpp:2201
cleanupguard.h
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:883
main
int main(int argc, char *argv[])
Definition: mythfilldatabase.cpp:44
DataSource::userid
QString userid
Definition: filldata.h:30
MythCommandLineParser::toStringList
QStringList toStringList(const QString &key, const QString &sep="") const
Returns stored QVariant as a QStringList, falling to default if not provided.
Definition: mythcommandlineparser.cpp:2389
GENERIC_EXIT_DB_OUTOFDATE
@ GENERIC_EXIT_DB_OUTOFDATE
Database needs upgrade.
Definition: exitcodes.h:17
FillData::SetRefresh
void SetRefresh(int day, bool set)
Definition: filldata.cpp:69
mythcontext.h
ChannelData::m_filterNewChannels
bool m_filterNewChannels
Definition: channeldata.h:32
FillData::m_refreshTba
bool m_refreshTba
Definition: filldata.h:71
DataSource::xmltvgrabber_baseline
bool xmltvgrabber_baseline
Definition: filldata.h:33
MSqlQuery::numRowsAffected
int numRowsAffected() const
Definition: mythdbcon.h:218
DataSource::xmltvgrabber_manualconfig
bool xmltvgrabber_manualconfig
Definition: filldata.h:34
MythCommandLineParser::ConfigureLogging
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
Definition: mythcommandlineparser.cpp:2862
myth_nice
bool myth_nice(int val)
Definition: mythmiscutil.cpp:657
FillData::m_noAllAtOnce
bool m_noAllAtOnce
Definition: filldata.h:75
updateLastRunStatus
bool updateLastRunStatus(QString &status)
Definition: filldata.cpp:54
MythTranslation::load
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
Definition: mythtranslation.cpp:37
exitcodes.h
MythCommandLineParser::toInt
int toInt(const QString &key) const
Returns stored QVariant as an integer, falling to default if not provided.
Definition: mythcommandlineparser.cpp:2223
DataSource::id
int id
Definition: filldata.h:27
GENERIC_EXIT_INVALID_CMDLINE
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
Definition: exitcodes.h:16
FillData::m_needPostGrabProc
bool m_needPostGrabProc
Definition: filldata.h:72
MythCommandLineParser::GetPassthrough
QString GetPassthrough(void) const
Return any text supplied on the command line after a bare '–'.
Definition: mythcommandlineparser.cpp:2103
FillData::m_maxDays
uint m_maxDays
Definition: filldata.h:67
ScheduledRecording::RescheduleMatch
static void RescheduleMatch(uint recordid, uint sourceid, uint mplexid, const QDateTime &maxstarttime, const QString &why)
Definition: scheduledrecording.h:17
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:889
DataSource::xmltvgrabber_cache
bool xmltvgrabber_cache
Definition: filldata.h:35
DataSource::password
QString password
Definition: filldata.h:31
gContext
MythContext * gContext
This global variable contains the MythContext instance for the application.
Definition: mythcontext.cpp:57
videosource.h
MythContext::Init
bool Init(bool gui=true, bool promptForBackend=false, bool disableAutoDiscovery=false, bool ignoreDB=false)
Definition: mythcontext.cpp:1584
SignalHandler::Done
static void Done(void)
Definition: signalhandling.cpp:134
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:832
FillData::kRefreshAll
@ kRefreshAll
Definition: filldata.h:59
GENERIC_EXIT_DB_ERROR
@ GENERIC_EXIT_DB_ERROR
Database error.
Definition: exitcodes.h:18