Skip to content

Commit

Permalink
eitfixup: Convert Finnish fixups to QRegularExpression.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Feb 16, 2021
1 parent 6f371f0 commit 2c180c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 34 deletions.
46 changes: 22 additions & 24 deletions mythtv/libs/libmythtv/eitfixup.cpp
Expand Up @@ -46,11 +46,7 @@ int EITFixUp::parseRoman (QString roman)


EITFixUp::EITFixUp()
: m_fiRerun(R"(\ ?Uusinta[a-zA-Z\ ]*\.?)"),
m_fiRerun2("\\([Uu]\\)"),
m_fiAgeLimit("\\(((1?[0-9]?)|[ST])\\)$"),
m_fiFilm("^(Film|Elokuva): "),
m_nlTxt("txt"),
: m_nlTxt("txt"),
m_nlWide("breedbeeld"),
m_nlRepeat("herh."),
m_nlHD("\\sHD$"),
Expand Down Expand Up @@ -1909,53 +1905,55 @@ void EITFixUp::FixATV(DBEventEIT &event)
}


/** \fn EITFixUp::FixFI(DBEventEIT&) const
/**
* \brief Use this to clean DVB-T guide in Finland.
*/
void EITFixUp::FixFI(DBEventEIT &event) const
void EITFixUp::FixFI(DBEventEIT &event)
{
int position = event.m_description.indexOf(m_fiRerun);
if (position != -1)
QRegularExpression fiRerun { R"(\s?Uusinta[a-zA-Z\s]*\.?)" };
auto match = fiRerun.match(event.m_description);
if (match.hasMatch())
{
event.m_previouslyshown = true;
event.m_description = event.m_description.replace(m_fiRerun, "");
event.m_description.remove(match.capturedStart(), match.capturedLength());
}

position = event.m_description.indexOf(m_fiRerun2);
if (position != -1)
QRegularExpression fiRerun2 { R"(\([Uu]\))" };
match = fiRerun2.match(event.m_description);
if (match.hasMatch())
{
event.m_previouslyshown = true;
event.m_description = event.m_description.replace(m_fiRerun2, "");
event.m_description.remove(match.capturedStart(), match.capturedLength());
}

// Check for (Stereo) in the decription and set the <audio> tags
auto match = kStereo.match(event.m_description);
match = kStereo.match(event.m_description);
if (match.hasMatch())
{
event.m_audioProps |= AUD_STEREO;
event.m_description.remove(match.capturedStart(0),
match.capturedLength(0));
event.m_description.remove(match.capturedStart(), match.capturedLength());
}

// Remove age limit in parenthesis at end of title
position = m_fiAgeLimit.indexIn(event.m_title);
if (position != -1)
QRegularExpression fiAgeLimit { R"(\((\d{1,2}|[ST])\)$)" };
match = fiAgeLimit.match(event.m_title);
if (match.hasMatch())
{
EventRating prograting;
prograting.m_system="FI"; prograting.m_rating = m_fiAgeLimit.cap(1);
prograting.m_system="FI"; prograting.m_rating = match.captured(1);
event.m_ratings.push_back(prograting);
event.m_title.remove(position, m_fiAgeLimit.matchedLength());
event.m_title.remove(match.capturedStart(), match.capturedLength());
}

// Remove Film or Elokuva at start of title
position = event.m_title.indexOf(m_fiFilm);
if (position != -1)
QRegularExpression fiFilm { "^(Film|Elokuva): " };
match = fiFilm.match(event.m_title);
if (match.hasMatch())
{
event.m_category = "Film";
event.m_categoryType = ProgramInfo::kCategoryMovie;
event.m_title = event.m_title.replace(m_fiFilm, "");
event.m_title.remove(match.capturedStart(), match.capturedLength());
}

}

/** \fn EITFixUp::FixPremiere(DBEventEIT&) const
Expand Down
6 changes: 1 addition & 5 deletions mythtv/libs/libmythtv/eitfixup.h
Expand Up @@ -108,7 +108,7 @@ class MTV_PUBLIC EITFixUp
static void FixPRO7(DBEventEIT &event); // Pro7/Sat1 Group
static void FixDisneyChannel(DBEventEIT &event);// Disney Channel
static void FixATV(DBEventEIT &event); // ATV/ATV2
void FixFI(DBEventEIT &event) const; // Finland DVB-T
static void FixFI(DBEventEIT &event); // Finland DVB-T
static void FixPremiere(DBEventEIT &event); // german pay-tv Premiere
void FixNL(DBEventEIT &event) const; // Netherlands DVB-C
static void FixCategory(DBEventEIT &event); // Generic Category fixes
Expand All @@ -123,10 +123,6 @@ class MTV_PUBLIC EITFixUp

static QString AddDVBEITAuthority(uint chanid, const QString &id);

const QRegExp m_fiRerun;
const QRegExp m_fiRerun2;
const QRegExp m_fiAgeLimit;
const QRegExp m_fiFilm;
const QRegExp m_nlTxt;
const QRegExp m_nlWide;
const QRegExp m_nlRepeat;
Expand Down
6 changes: 1 addition & 5 deletions mythtv/libs/libmythtv/test/test_eitfixups/test_eitfixups.cpp
Expand Up @@ -2658,11 +2658,7 @@ void TestEITFixups::testFI_data()
<< "Title" << "Subtitle" << "Description."
<< true << "" << ProgramInfo::kCategoryNone
<< (int)AUD_UNKNOWN << true << "17";
QTest::newRow("rating5") << "Title ()" << "Subtitle" << "Description. (u)"
<< "Title" << "Subtitle" << "Description."
<< true << "" << ProgramInfo::kCategoryNone
<< (int)AUD_UNKNOWN << true << ""; // Oops?
QTest::newRow("rating6") << "Title (17)" << "Subtitle" << "Description. (u) Stereo"
QTest::newRow("rating5") << "Title (17)" << "Subtitle" << "Description. (u) Stereo"
<< "Title" << "Subtitle" << "Description."
<< true << "" << ProgramInfo::kCategoryNone
<< (int)AUD_STEREO << true << "17";
Expand Down

0 comments on commit 2c180c4

Please sign in to comment.