128 changes: 66 additions & 62 deletions mythtv/libs/libmythtv/eitfixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
static const QRegularExpression kStereo { R"(\b\(?[sS]tereo\)?\b)" };
static const QRegularExpression kUKSpaceColonStart { R"(^[ |:]*)" };

#if QT_VERSION < QT_VERSION_CHECK(5,15,2)
#define capturedView capturedRef
#endif

static const QMap<QChar,quint16> r2v = {
{'I' , 1}, {'V' , 5}, {'X' , 10}, {'L' , 50},
{'C' , 100}, {'D' , 500}, {'M' , 1000},
Expand Down Expand Up @@ -1057,15 +1061,15 @@ void EITFixUp::FixComHem(DBEventEIT &event, bool process_subtitle)
auto match2 = comHemSeries2.match(event.m_title);
if (match2.hasMatch())
{
event.m_partnumber = match2.capturedRef(2).toUInt();
event.m_partnumber = match2.capturedView(2).toUInt();
event.m_title.remove(match2.capturedStart(), match2.capturedLength());
}
else if (match.hasMatch())
{
if (match.capturedStart(1) != -1)
event.m_partnumber = match.capturedRef(1).toUInt();
event.m_partnumber = match.capturedView(1).toUInt();
if (match.capturedStart(2) != -1)
event.m_parttotal = match.capturedRef(2).toUInt();
event.m_parttotal = match.capturedView(2).toUInt();

// Remove the episode numbers, but only if it's not at the begining
// of the description (subtitle code might use it)
Expand Down Expand Up @@ -1108,45 +1112,45 @@ void EITFixUp::FixComHem(DBEventEIT &event, bool process_subtitle)

// Original title, usually english title
// note: list[1] contains extra () around the text that needs removing
if (!match.capturedRef(1).isEmpty())
if (!match.capturedView(1).isEmpty())
{
replacement = match.capturedRef(1) + " ";
replacement = match.captured(1) + " ";
//store it somewhere?
}

// Countr(y|ies)
if (!match.capturedRef(2).isEmpty())
if (!match.capturedView(2).isEmpty())
{
replacement += match.capturedRef(2) + " ";
replacement += match.captured(2) + " ";
//store it somewhere?
}

// Category
if (!match.capturedRef(3).isEmpty())
if (!match.capturedView(3).isEmpty())
{
replacement += match.capturedRef(3) + ".";
replacement += match.captured(3) + ".";
if(event.m_category.isEmpty())
{
event.m_category = match.captured(3);
}

if(match.capturedRef(3).indexOf("serie")!=-1)
if(match.captured(3).indexOf("serie")!=-1)
{
isSeries = true;
}
}

// Year
if (!match.capturedRef(4).isEmpty())
if (!match.capturedView(4).isEmpty())
{
bool ok = false;
uint y = match.capturedRef(4).trimmed().toUInt(&ok);
uint y = match.capturedView(4).trimmed().toUInt(&ok);
if (ok)
event.m_airdate = y;
}

// Actors
if (!match.capturedRef(5).isEmpty())
if (!match.capturedView(5).isEmpty())
{
#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
const QStringList actors =
Expand Down Expand Up @@ -1180,9 +1184,9 @@ void EITFixUp::FixComHem(DBEventEIT &event, bool process_subtitle)
static const QRegularExpression comHemDirector { "[Rr]egi" };
static const QRegularExpression comHemActor { "[Ss]kådespelare|[Ii] rollerna" };
static const QRegularExpression comHemHost { "[Pp]rogramledare" };
auto dmatch = comHemDirector.match(pmatch.capturedRef(1));
auto amatch = comHemActor.match(pmatch.capturedRef(1));
auto hmatch = comHemHost.match(pmatch.capturedRef(1));
auto dmatch = comHemDirector.match(pmatch.capturedView(1));
auto amatch = comHemActor.match(pmatch.capturedView(1));
auto hmatch = comHemHost.match(pmatch.capturedView(1));
if (dmatch.hasMatch())
role = DBPerson::kDirector;
else if (amatch.hasMatch())
Expand Down Expand Up @@ -1239,28 +1243,28 @@ void EITFixUp::FixComHem(DBEventEIT &event, bool process_subtitle)
return;

// Rerun from today
if (match.capturedRef(1) == "i dag")
if (match.captured(1) == "i dag")
{
event.m_originalairdate = event.m_starttime.date();
return;
}

// Rerun from yesterday afternoon
if (match.capturedRef(1) == "eftermiddagen")
if (match.captured(1) == "eftermiddagen")
{
event.m_originalairdate = event.m_starttime.date().addDays(-1);
return;
}

// Rerun with day, month and possibly year specified
match2 = comHemRerun2.match(match.capturedRef(1));
match2 = comHemRerun2.match(match.capturedView(1));
if (match2.hasMatch())
{
int day = match2.capturedRef(1).toInt();
int month = match2.capturedRef(2).toInt();
int day = match2.capturedView(1).toInt();
int month = match2.capturedView(2).toInt();
//int year;
//if (match2.capturedLength(3) > 0)
// year = match2.capturedRef(3).toInt();
// year = match2.capturedView(3).toInt();
//else
// year = event.m_starttime.date().year();

Expand Down Expand Up @@ -1365,7 +1369,7 @@ void EITFixUp::FixAUSeven(DBEventEIT &event)
auto match = year.match(event.m_description);
if (match.hasMatch())
{
event.m_airdate = match.capturedRef(1).toUInt();
event.m_airdate = match.capturedView(1).toUInt();
event.m_description.resize(event.m_description.size()-5);
}
if (event.m_description.endsWith(" CC"))
Expand Down Expand Up @@ -1410,15 +1414,15 @@ void EITFixUp::FixAUFreeview(DBEventEIT &event)
{
if (event.m_subtitle.isEmpty())//nine sometimes has an actual subtitle field and the brackets thingo)
event.m_subtitle = match.captured(2);
event.m_airdate = match.capturedRef(3).toUInt();
event.m_airdate = match.capturedView(3).toUInt();
event.m_description = match.captured(1);
return;
}
static const QRegularExpression auFreeviewY { "(.*) \\(([12][0-9][0-9][0-9])\\)$" };
match = auFreeviewY.match(event.m_description);
if (match.hasMatch())
{
event.m_airdate = match.capturedRef(2).toUInt();
event.m_airdate = match.capturedView(2).toUInt();
event.m_description = match.captured(1);
return;
}
Expand All @@ -1428,7 +1432,7 @@ void EITFixUp::FixAUFreeview(DBEventEIT &event)
{
if (event.m_subtitle.isEmpty())
event.m_subtitle = match.captured(2);
event.m_airdate = match.capturedRef(3).toUInt();
event.m_airdate = match.capturedView(3).toUInt();
QStringList actors = match.captured(4).split("/");
for (int i = 0; i < actors.size(); ++i)
event.AddPerson(DBPerson::kActor, actors.at(i));
Expand All @@ -1439,7 +1443,7 @@ void EITFixUp::FixAUFreeview(DBEventEIT &event)
match = auFreeviewYC.match(event.m_description);
if (match.hasMatch())
{
event.m_airdate = match.capturedRef(2).toUInt();
event.m_airdate = match.capturedView(2).toUInt();
QStringList actors = match.captured(3).split("/");
for (int i = 0; i < actors.size(); ++i)
event.AddPerson(DBPerson::kActor, actors.at(i));
Expand Down Expand Up @@ -1470,7 +1474,7 @@ void EITFixUp::FixMCA(DBEventEIT &event)
static const QString mcaCompleteTitlea { "^'?(" };
static const QString mcaCompleteTitleb { R"([^\.\?]+[^\'])'?[\.\?]\s+(.+))" };
static const QRegularExpression mcaCompleteTitle
{ mcaCompleteTitlea + match.capturedRef(1) + mcaCompleteTitleb,
{ mcaCompleteTitlea + match.captured(1) + mcaCompleteTitleb,
QRegularExpression::CaseInsensitiveOption};
match = mcaCompleteTitle.match(event.m_description);
if (match.hasMatch())
Expand Down Expand Up @@ -1501,8 +1505,8 @@ void EITFixUp::FixMCA(DBEventEIT &event)
match = mcaSeries.match(event.m_subtitle);
if (match.hasMatch())
{
uint season = match.capturedRef(1).toUInt();
uint episode = match.capturedRef(2).toUInt();
uint season = match.capturedView(1).toUInt();
uint episode = match.capturedView(2).toUInt();
event.m_subtitle = match.captured(3).trimmed();
event.m_syndicatedepisodenumber =
QString("S%1E%2").arg(season).arg(episode);
Expand Down Expand Up @@ -1596,7 +1600,7 @@ void EITFixUp::FixRTL(DBEventEIT &event)
if (match.hasMatch())
{
event.m_season = 0;
event.m_episode = match.capturedRef(1).toUInt();
event.m_episode = match.capturedView(1).toUInt();
event.m_subtitle = match.captured(2);
}

Expand Down Expand Up @@ -2122,7 +2126,7 @@ void EITFixUp::FixNL(DBEventEIT &event)
if (match.hasMatch())
{
bool ok = false;
uint y = match.capturedRef(1).toUInt(&ok);
uint y = match.capturedView(1).toUInt(&ok);
if (ok)
event.m_originalairdate = QDate(y, 1, 1);
}
Expand All @@ -2131,7 +2135,7 @@ void EITFixUp::FixNL(DBEventEIT &event)
if (match.hasMatch())
{
bool ok = false;
uint y = match.capturedRef(2).toUInt(&ok);
uint y = match.capturedView(2).toUInt(&ok);
if (ok)
event.m_originalairdate = QDate(y, 1, 1);
}
Expand Down Expand Up @@ -2231,7 +2235,7 @@ void EITFixUp::FixNRK_DVBT(DBEventEIT &event)
if (match.hasMatch() && (match.capturedLength(2) > 1))
{
event.m_title = match.captured(2);
event.m_description = "(" + match.capturedRef(1) + ") " + event.m_description;
event.m_description = "(" + match.captured(1) + ") " + event.m_description;
}

// Remove season premiere markings
Expand Down Expand Up @@ -2278,18 +2282,18 @@ void EITFixUp::FixDK(DBEventEIT &event)
auto match = dkEpisode.match(event.m_title);
if (match.hasMatch())
{
episode = match.capturedRef(1).toInt();
event.m_partnumber = match.capturedRef(1).toInt();
episode = match.capturedView(1).toInt();
event.m_partnumber = match.capturedView(1).toInt();
event.m_title.remove(match.capturedStart(), match.capturedLength());
}

static const QRegularExpression dkPart { R"(\(([0-9]+):([0-9]+)\))" };
match = dkPart.match(event.m_title);
if (match.hasMatch())
{
episode = match.capturedRef(1).toInt();
event.m_partnumber = match.capturedRef(1).toInt();
event.m_parttotal = match.capturedRef(2).toInt();
episode = match.capturedView(1).toInt();
event.m_partnumber = match.capturedView(1).toInt();
event.m_parttotal = match.capturedView(2).toInt();
event.m_title.remove(match.capturedStart(), match.capturedLength());
}

Expand Down Expand Up @@ -2319,15 +2323,15 @@ void EITFixUp::FixDK(DBEventEIT &event)
match = dkSeason1.match(event.m_description);
if (match.hasMatch())
{
season = match.capturedRef(1).toInt();
season = match.capturedView(1).toInt();
}
else
{
static const QRegularExpression dkSeason2 { "- år ([0-9]+) :" };
match = dkSeason2.match(event.m_description);
if (match.hasMatch())
{
season = match.capturedRef(1).toInt();
season = match.capturedView(1).toInt();
}
}

Expand Down Expand Up @@ -2468,7 +2472,7 @@ void EITFixUp::FixDK(DBEventEIT &event)
if (match.hasMatch())
{
bool ok = false;
uint y = match.capturedRef(1).toUInt(&ok);
uint y = match.capturedView(1).toUInt(&ok);
if (ok)
event.m_originalairdate = QDate(y, 1, 1);
}
Expand Down Expand Up @@ -2664,7 +2668,7 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event)
if (match.hasMatch())
{
bool ok = false;
uint y = match.capturedRef(1).toUInt(&ok);
uint y = match.capturedView(1).toUInt(&ok);
if (ok)
{
event.m_originalairdate = QDate(y, 1, 1);
Expand Down Expand Up @@ -2693,35 +2697,35 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event)
match = grSeason.match(event.m_title);
if (match.hasMatch())
{
if (!match.capturedRef(2).isEmpty()) // we found a letter representing a number
if (!match.capturedView(2).isEmpty()) // we found a letter representing a number
{
//sometimes Nat. TV writes numbers as letters, i.e Α=1, Β=2, Γ=3, etc
//must convert them to numbers.
int tmpinteger = match.capturedRef(2).toUInt();
int tmpinteger = match.capturedView(2).toUInt();
if (tmpinteger < 1)
{
if (match.capturedRef(2) == "ΣΤ") // 6, don't ask!
if (match.captured(2) == "ΣΤ") // 6, don't ask!
event.m_season = 6;
else
{
static const QString LettToNumber = "0ΑΒΓΔΕ6ΖΗΘΙΚΛΜΝ";
tmpinteger = LettToNumber.indexOf(match.capturedRef(2));
tmpinteger = LettToNumber.indexOf(match.capturedView(2));
if (tmpinteger != -1)
event.m_season = tmpinteger;
else
//sometimes they use english letters instead of greek. Compensating:
{
static const QString LettToNumber2 = "0ABΓΔE6ZHΘIKΛMN";
tmpinteger = LettToNumber2.indexOf(match.capturedRef(2));
tmpinteger = LettToNumber2.indexOf(match.capturedView(2));
if (tmpinteger != -1)
event.m_season = tmpinteger;
}
}
}
}
else if (!match.capturedRef(3).isEmpty()) //number
else if (!match.capturedView(3).isEmpty()) //number
{
event.m_season = match.capturedRef(3).toUInt();
event.m_season = match.capturedView(3).toUInt();
}
series = true;
event.m_title.remove(match.capturedStart(), match.capturedLength());
Expand All @@ -2731,27 +2735,27 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event)
match = grSeason.match(event.m_description);
if (match.hasMatch())
{
if (!match.capturedRef(2).isEmpty()) // we found a letter representing a number
if (!match.capturedView(2).isEmpty()) // we found a letter representing a number
{
//sometimes Nat. TV writes numbers as letters, i.e Α=1, Β=2, Γ=3, etc
//must convert them to numbers.
int tmpinteger = match.capturedRef(2).toUInt();
int tmpinteger = match.capturedView(2).toUInt();
if (tmpinteger < 1)
{
if (match.capturedRef(2) == "ΣΤ") // 6, don't ask!
if (match.captured(2) == "ΣΤ") // 6, don't ask!
event.m_season = 6;
else
{
static const QString LettToNumber = "0ΑΒΓΔΕ6ΖΗΘΙΚΛΜΝ";
tmpinteger = LettToNumber.indexOf(match.capturedRef(2));
tmpinteger = LettToNumber.indexOf(match.capturedView(2));
if (tmpinteger != -1)
event.m_season = tmpinteger;
}
}
}
else if (!match.capturedRef(3).isEmpty()) //number
else if (!match.capturedView(3).isEmpty()) //number
{
event.m_season = match.capturedRef(3).toUInt();
event.m_season = match.capturedView(3).toUInt();
}
series = true;
event.m_description.remove(match.capturedStart(), match.capturedLength());
Expand All @@ -2765,7 +2769,7 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event)
auto match2 = grSeasonAsRomanNumerals.match(event.m_description);
if (match.hasMatch())
{
if (!match.capturedRef(1).isEmpty()) //number
if (!match.capturedView(1).isEmpty()) //number
event.m_season = parseRoman(match.captured(1).toUpper());
series = true;
event.m_title.remove(match.capturedStart(), match.capturedLength());
Expand All @@ -2775,7 +2779,7 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event)
}
else if (match2.hasMatch())
{
if (!match2.capturedRef(1).isEmpty()) //number
if (!match2.capturedView(1).isEmpty()) //number
event.m_season = parseRoman(match2.captured(1).toUpper());
series = true;
event.m_description.remove(match2.capturedStart(), match2.capturedLength());
Expand All @@ -2791,15 +2795,15 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event)
match2 = grlongEp.match(event.m_description);
if (match.hasMatch() || match2.hasMatch())
{
if (!match.capturedRef(1).isEmpty())
if (!match.capturedView(1).isEmpty())
{
event.m_episode = match.capturedRef(1).toUInt();
event.m_episode = match.capturedView(1).toUInt();
series = true;
event.m_title.remove(match.capturedStart(), match.capturedLength());
}
else if (!match2.capturedRef(1).isEmpty())
else if (!match2.capturedView(1).isEmpty())
{
event.m_episode = match2.capturedRef(1).toUInt();
event.m_episode = match2.capturedView(1).toUInt();
series = true;
event.m_description.remove(match2.capturedStart(), match2.capturedLength());
}
Expand Down