Skip to content

Commit

Permalink
Alter mythfilldatabase day specification parameters
Browse files Browse the repository at this point in the history
This commit replaces the following command line options with --refresh:
    --refresh-today
    --dont-refresh-tomorrow
    --refresh-second
    --refresh-day
    --refresh-all

The old options will continue to function for now, but will be hidden
from the help printout.

Each instance of the --refresh option takes one input, and the option
can be specified multiple times.  The three named options can be
pre-pended by the 'not' parameter, specifying that day should not be
pulled.  Numbered days start with today at zero, counting up, and a
range can be specified using a dash.

The following example will refresh today, skip tomorrow, and refresh
all of next week:

mythfilldatabase --refresh today --refresh nottomorrow --refresh 7-13
  • Loading branch information
wagnerrp committed Sep 19, 2011
1 parent 8b41156 commit eed7862
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 12 deletions.
27 changes: 20 additions & 7 deletions mythtv/programs/mythfilldatabase/commandlineparser.cpp
Expand Up @@ -103,32 +103,45 @@ void MythFillDatabaseCommandLineParser::LoadArguments(void)
"in case MythTV's smarts fail you.");
// need documentation for this one
add("--cardtype", "cardtype", "", "", "No information.");

add("--refresh", "refresh", QVariant::StringList,
"Provide a day or range of days to refresh. Can be "
"used repeatedly.",
"Provide days to refresh during the grabber run. Multiple \n"
"days or ranges can be supplied by multiple instances of the \n"
"option. Supported days are:\n"
" [not]today\n"
" [not]tomorrow\n"
" [not]second\n"
" #[-#]\n"
" all\n\n"
"example:\n"
" --refresh today --refresh 4-8 --refresh nottomorrow");

add("--max-days", "maxdays", 0, "force number of days to update",
"Force the maximum number of days, counting today, "
"for the guide data grabber to check for future "
"listings.");
add("--refresh-today", "refreshtoday", false, "refresh today's listings",
add("--refresh-today", "refreshtoday", false, "",
"This option is only valid for selected grabbers.\n"
"Force a refresh for today's guide data.\nThis can be used "
"in combination with other --refresh-<n> options.\n"
"If being used with datadirect, this option should not be "
"used, rather use --dd-grab-all to pull all listings each time.");
add("--dont-refresh-tomorrow", "dontrefreshtomorrow", false,
"don't refresh tomorrow's listings",
add("--dont-refresh-tomorrow", "dontrefreshtomorrow", false, "",
"This option is only valid for selected grabbers.\n"
"Prevent mythfilldatabase from pulling information for "
"tomorrow's listings. Data for tomorrow is always pulled "
"unless specifically specified otherwise.\n"
"If being used with datadirect, this option should not be "
"used, rather use --dd-grab-all to pull all listings each time.");
add("--refresh-second", "refreshsecond", false,
"refresh listings two days from now",
add("--refresh-second", "refreshsecond", false, "",
"This option is only valid for selected grabbers.\n"
"Force a refresh for guide data two days from now. This can "
"be used in combination with other --refresh-<n> options.\n"
"If being used with datadirect, this option should not be "
"used, rather use --dd-grab-all to pull all listings each time.");
add("--refresh-day", "refreshday", 0U, "refresh specific day's listings",
add("--refresh-day", "refreshday", 0U, "",
"This option is only valid for selected grabbers.\n"
"Force a refresh for guide data on a specific day. This can "
"be used in combination with other --refresh-<n> options.\n"
Expand All @@ -142,7 +155,7 @@ void MythFillDatabaseCommandLineParser::LoadArguments(void)
"If being used with datadirect, this option should not be "
"used, rather use --dd-grab-all to pull all listings each time.");

add("--refresh-all", "refreshall", false, "refresh listings on all days",
add("--refresh-all", "refreshall", false, "",
"This option is only valid for selected grabbers.\n"
"This option forces a refresh of all guide data, but does so "
"with fourteen downloads of one day each.\n"
Expand Down
82 changes: 77 additions & 5 deletions mythtv/programs/mythfilldatabase/main.cpp
Expand Up @@ -233,16 +233,88 @@ int main(int argc, char *argv[])
if (fill_data.maxDays == 1)
fill_data.SetRefresh(0, true);
}

if (cmdline.toBool("refreshtoday"))
fill_data.SetRefresh(0, true);
cmdline.SetValue("refresh",
cmdline.toStringList("refresh") << "today");
if (cmdline.toBool("dontrefreshtomorrow"))
fill_data.SetRefresh(1, false);
cmdline.SetValue("refresh",
cmdline.toStringList("refresh") << "nottomorrow");
if (cmdline.toBool("refreshsecond"))
fill_data.SetRefresh(2, true);
cmdline.SetValue("refresh",
cmdline.toStringList("refresh") << "today");
if (cmdline.toBool("refreshall"))
fill_data.SetRefresh(FillData::kRefreshAll, true);
cmdline.SetValue("refresh",
cmdline.toStringList("refresh") << "all");
if (cmdline.toBool("refreshday"))
fill_data.SetRefresh(cmdline.toUInt("refreshday"), true);
cmdline.SetValue("refresh",
cmdline.toStringList("refresh") <<
QString::number(cmdline.toUInt("refreshday")));

QStringList sl =cmdline.toStringList("refresh");
if (!sl.isEmpty())
{
QStringList::const_iterator i = sl.constBegin();
for (; i != sl.constEnd(); ++i)
{
QString warn = QString("Invalid entry in --refresh list: %1")
.arg(*i);

bool enable = (*i).contains("not") ? false : true;

if ((*i).contains("today"))
fill_data.SetRefresh(0, enable);
else if ((*i).contains("tomorrow"))
fill_data.SetRefresh(1, enable);
else if ((*i).contains("second"))
fill_data.SetRefresh(2, enable);
else if ((*i).contains("all"))
fill_data.SetRefresh(FillData::kRefreshAll, enable);
else if ((*i).contains("-"))
{
bool ok;
QStringList r = (*i).split("-");

uint lower = r[0].toUInt(&ok);
if (!ok)
{
cerr << warn.toLocal8Bit().constData() << endl;
return false;
}

uint upper = r[1].toUInt(&ok);
if (!ok)
{
cerr << warn.toLocal8Bit().constData() << endl;
return false;
}

if (lower > upper)
{
cerr << warn.toLocal8Bit().constData() << endl;
return false;
}

for (uint j = lower; j <= upper; ++j)
fill_data.SetRefresh(j, true);
}
else
{
bool ok;
uint day = (*i).toUInt(&ok);
if (!ok)
{
cerr << warn.toLocal8Bit().constData() << endl;
return false;
}

fill_data.SetRefresh(day, true);
}
}
}

return 0;

if (cmdline.toBool("dontrefreshtba"))
fill_data.refresh_tba = false;
if (cmdline.toBool("ddgraball"))
Expand Down

0 comments on commit eed7862

Please sign in to comment.