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