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 
301  MSqlQuery query(MSqlQuery::InitCon());
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 
426  MSqlQuery query(MSqlQuery::InitCon());
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, 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, new_programid));
482  }
483  else
484  found += repl.numRowsAffected();
485  }
486  }
487 
488  LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
489 
490  LOG(VB_GENERAL, LOG_INFO, "Fixing missing original airdates.");
491  query.prepare("UPDATE program p "
492  "JOIN ( "
493  " SELECT programid, MAX(originalairdate) maxoad "
494  " FROM program "
495  " WHERE programid <> '' AND "
496  " originalairdate IS NOT NULL "
497  " GROUP BY programid ) oad "
498  " ON p.programid = oad.programid "
499  "SET p.originalairdate = oad.maxoad "
500  "WHERE p.originalairdate IS NULL");
501 
502  if (query.exec())
503  {
504  LOG(VB_GENERAL, LOG_INFO,
505  QString(" Found %1 with programids")
506  .arg(query.numRowsAffected()));
507  }
508 
509  query.prepare("UPDATE program p "
510  "JOIN ( "
511  " SELECT title, subtitle, description, "
512  " MAX(originalairdate) maxoad "
513  " FROM program "
514  " WHERE programid = '' AND "
515  " originalairdate IS NOT NULL "
516  " GROUP BY title, subtitle, description ) oad "
517  " ON p.programid = '' AND "
518  " p.title = oad.title AND "
519  " p.subtitle = oad.subtitle AND "
520  " p.description = oad.description "
521  "SET p.originalairdate = oad.maxoad "
522  "WHERE p.originalairdate IS NULL");
523 
524  if (query.exec())
525  {
526  LOG(VB_GENERAL, LOG_INFO,
527  QString(" Found %1 without programids")
528  .arg(query.numRowsAffected()));
529  }
530 
531  if (mark_repeats)
532  {
533  LOG(VB_GENERAL, LOG_INFO, "Marking repeats.");
534 
535  int newEpiWindow = gCoreContext->GetNumSetting( "NewEpisodeWindow", 14);
536 
537  MSqlQuery query2(MSqlQuery::InitCon());
538  query2.prepare("UPDATE program SET previouslyshown = 1 "
539  "WHERE previouslyshown = 0 "
540  "AND originalairdate is not null "
541  "AND (to_days(starttime) - to_days(originalairdate)) "
542  " > :NEWWINDOW;");
543  query2.bindValue(":NEWWINDOW", newEpiWindow);
544 
545  if (query2.exec())
546  LOG(VB_GENERAL, LOG_INFO,
547  QString(" Found %1").arg(query2.numRowsAffected()));
548 
549  LOG(VB_GENERAL, LOG_INFO, "Unmarking new episode rebroadcast repeats.");
550  query2.prepare("UPDATE program SET previouslyshown = 0 "
551  "WHERE previouslyshown = 1 "
552  "AND originalairdate is not null "
553  "AND (to_days(starttime) - to_days(originalairdate)) "
554  " <= :NEWWINDOW;");
555  query2.bindValue(":NEWWINDOW", newEpiWindow);
556 
557  if (query2.exec())
558  LOG(VB_GENERAL, LOG_INFO,
559  QString(" Found %1").arg(query2.numRowsAffected()));
560  }
561 
562  // Mark first and last showings
564  updt.prepare("UPDATE program SET first = 0, last = 0;");
565  if (!updt.exec())
566  MythDB::DBError("Clearing first and last showings", updt);
567 
568  LOG(VB_GENERAL, LOG_INFO, "Marking episode first showings.");
569  updt.prepare("UPDATE program "
570  "JOIN (SELECT MIN(p.starttime) AS starttime, p.programid "
571  " FROM program p, channel c "
572  " WHERE p.programid <> '' "
573  " AND p.chanid = c.chanid "
574  " AND c.deleted IS NULL "
575  " AND c.visible > 0 "
576  " GROUP BY p.programid "
577  " ) AS firsts "
578  "ON program.programid = firsts.programid "
579  " AND program.starttime = firsts.starttime "
580  "SET program.first=1;");
581  if (!updt.exec())
582  MythDB::DBError("Marking first showings by id", updt);
583  found = updt.numRowsAffected();
584 
585  updt.prepare("UPDATE program "
586  "JOIN (SELECT MIN(p.starttime) AS starttime, p.title, p.subtitle, "
587  " LEFT(p.description, 1024) AS partdesc "
588  " FROM program p, channel c "
589  " WHERE p.programid = '' "
590  " AND p.chanid = c.chanid "
591  " AND c.deleted IS NULL "
592  " AND c.visible > 0 "
593  " GROUP BY p.title, p.subtitle, partdesc "
594  " ) AS firsts "
595  "ON program.starttime = firsts.starttime "
596  " AND program.title = firsts.title "
597  " AND program.subtitle = firsts.subtitle "
598  " AND LEFT(program.description, 1024) = firsts.partdesc "
599  "SET program.first = 1 "
600  "WHERE program.programid = '';");
601  if (!updt.exec())
602  MythDB::DBError("Marking first showings", updt);
603  found += updt.numRowsAffected();
604  LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
605 
606  LOG(VB_GENERAL, LOG_INFO, "Marking episode last showings.");
607  updt.prepare("UPDATE program "
608  "JOIN (SELECT MAX(p.starttime) AS starttime, p.programid "
609  " FROM program p, channel c "
610  " WHERE p.programid <> '' "
611  " AND p.chanid = c.chanid "
612  " AND c.deleted IS NULL "
613  " AND c.visible > 0 "
614  " GROUP BY p.programid "
615  " ) AS lasts "
616  "ON program.programid = lasts.programid "
617  " AND program.starttime = lasts.starttime "
618  "SET program.last=1;");
619  if (!updt.exec())
620  MythDB::DBError("Marking last showings by id", updt);
621  found = updt.numRowsAffected();
622 
623  updt.prepare("UPDATE program "
624  "JOIN (SELECT MAX(p.starttime) AS starttime, p.title, p.subtitle, "
625  " LEFT(p.description, 1024) AS partdesc "
626  " FROM program p, channel c "
627  " WHERE p.programid = '' "
628  " AND p.chanid = c.chanid "
629  " AND c.deleted IS NULL "
630  " AND c.visible > 0 "
631  " GROUP BY p.title, p.subtitle, partdesc "
632  " ) AS lasts "
633  "ON program.starttime = lasts.starttime "
634  " AND program.title = lasts.title "
635  " AND program.subtitle = lasts.subtitle "
636  " AND LEFT(program.description, 1024) = lasts.partdesc "
637  "SET program.last = 1 "
638  "WHERE program.programid = '';");
639  if (!updt.exec())
640  MythDB::DBError("Marking last showings", updt);
641  found += updt.numRowsAffected();
642  LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));
643 
644 #if 1
645  // limit MSqlQuery's lifetime
646  MSqlQuery query2(MSqlQuery::InitCon());
647  query2.prepare("SELECT count(previouslyshown) "
648  "FROM program WHERE previouslyshown = 1;");
649  if (query2.exec() && query2.next())
650  {
651  if (query2.value(0).toInt() != 0)
652  gCoreContext->SaveSettingOnHost("HaveRepeats", "1", nullptr);
653  else
654  gCoreContext->SaveSettingOnHost("HaveRepeats", "0", nullptr);
655  }
656 #endif
657 
658  LOG(VB_GENERAL, LOG_INFO, "\n"
659  "===============================================================\n"
660  "| Attempting to contact the master backend for rescheduling. |\n"
661  "| If the master is not running, rescheduling will happen when |\n"
662  "| the master backend is restarted. |\n"
663  "===============================================================");
664 
665  ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(),
666  "MythFillDatabase");
667 
668  gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
669 
670  gCoreContext->SendSystemEvent("MYTHFILLDATABASE_RAN");
671 
672  LOG(VB_GENERAL, LOG_NOTICE, "mythfilldatabase run complete.");
673 
674  return GENERIC_EXIT_OK;
675 }
676 
677 /* 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:802
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:124
Source::lineupid
QString lineupid
Definition: filldata.h:32
MythCoreContext::SendMessage
void SendMessage(const QString &message)
Definition: mythcorecontext.cpp:1529
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:211
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:854
MSqlQuery::isNull
bool isNull(int field) const
Definition: mythdbcon.h:216
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:43
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:201
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
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:370
mythversion.h
MythCommandLineParser::Parse
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
Definition: mythcommandlineparser.cpp:1449
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:1645
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:234
Source
Definition: channelsettings.cpp:68
Source::xmltvgrabber_baseline
bool xmltvgrabber_baseline
Definition: filldata.h:33
dbcheck.h
MythCoreContext::SendSystemEvent
void SendSystemEvent(const QString &msg)
Definition: mythcorecontext.cpp:1556
MythFillDatabaseCommandLineParser
Definition: mythfilldatabase/commandlineparser.h:6
signalhandling.h
commandlineparser.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:6
Source::userid
QString userid
Definition: filldata.h:30
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:200
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:214
MythCommandLineParser::PrintVersion
static void PrintVersion(void)
Print application version information.
Definition: mythcommandlineparser.cpp:1277
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:1293
FillData::m_chanData
ChannelData m_chanData
Definition: filldata.h:61
uint
unsigned int uint
Definition: compat.h:140
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:936
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:74
FillData
Definition: filldata.h:40
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:2252
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:2723
MythCommandLineParser::toBool
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
Definition: mythcommandlineparser.cpp:2095
cleanupguard.h
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:878
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:2283
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:214
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:2756
myth_nice
bool myth_nice(int val)
Definition: mythmiscutil.cpp:704
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:2117
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:1999
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
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:915
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:1570
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:827
FillData::kRefreshAll
@ kRefreshAll
Definition: filldata.h:57
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