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