Permalink
Browse files

Add Australian EIT fixups.

This is a good first pass, any further improvements welcomed.

Fixes #10098
  • Loading branch information...
stuarta authored and jyavenard committed Mar 1, 2013
1 parent d98a6f3 commit 914442c91830af93fb90586eac1cc216b0e13a4d
@@ -142,7 +142,11 @@ EITFixUp::EITFixUp()
m_dkActors("(?:Medvirkende: |Medv\\.: )(.+)"),
m_dkPersonsSeparator("(, )|(og )"),
m_dkDirector("(?:Instr.: |Instrukt.r: )(.+)$"),
m_dkYear(" fra ([0-9]{4})[ \\.]")
m_dkYear(" fra ([0-9]{4})[ \\.]"),
m_AUFreeviewSY("(.*) \\((.+)\\) \\(([12][0-9][0-9][0-9])\\)$"),
m_AUFreeviewY("(.*) \\(([12][0-9][0-9][0-9])\\)$"),
m_AUFreeviewYC("(.*) \\(([12][0-9][0-9][0-9])\\) \\((.+)\\)$"),
m_AUFreeviewSYC("(.*) \\((.+)\\) \\(([12][0-9][0-9][0-9])\\) \\((.+)\\)$")
{
}
@@ -181,6 +185,18 @@ void EITFixUp::Fix(DBEventEIT &event) const
if (kFixAUStar & event.fixup)
FixAUStar(event);
if (kFixAUDescription & event.fixup)
FixAUDescription(event);
if (kFixAUFreeview & event.fixup)
FixAUFreeview(event);
if (kFixAUNine & event.fixup)
FixAUNine(event);
if (kFixAUSeven & event.fixup)
FixAUSeven(event);
if (kFixMCA & event.fixup)
FixMCA(event);
@@ -1178,6 +1194,141 @@ void EITFixUp::FixAUStar(DBEventEIT &event) const
}
}
/** \fn EITFixUp::FixAUDescription(DBEventEIT&) const
* \brief Use this to standardize DVB-T guide in Australia. (fix common annoyances common to most networks)
*/
void EITFixUp::FixAUDescription(DBEventEIT &event) const
{
if (event.description.startsWith("[Program data ") || event.description.startsWith("[Program info "))//TEN
{
event.description = "";//event.subtitle;
}
if (event.description.endsWith("Copyright West TV Ltd. 2011)"))
event.description.resize(event.description.length()-40);
if (event.description.isEmpty() && !event.subtitle.isEmpty())//due to ten's copyright info, this won't be caught before
{
event.description = event.subtitle;
event.subtitle = QString::null;
}
if (event.description.startsWith(event.title+" - "))
event.description.remove(0,event.title.length()+3);
if (event.title.startsWith("LIVE: ", Qt::CaseInsensitive))
{
event.title.remove(0, 6);
event.description.prepend("(Live) ");
}
}
/** \fn EITFixUp::FixAUNine(DBEventEIT&) const
* \brief Use this to standardize DVB-T guide in Australia. (Nine network)
*/
void EITFixUp::FixAUNine(DBEventEIT &event) const
{
QRegExp rating("\\((G|PG|M|MA)\\)");
if (rating.indexIn(event.description) == 0)
{
EventRating prograting;
prograting.system="AU"; prograting.rating = rating.cap(1);
event.ratings.push_back(prograting);
event.description.remove(0,rating.matchedLength()+1);
}
if (event.description.startsWith("[HD]"))
{
event.videoProps |= VID_HDTV;
event.description.remove(0,5);
}
if (event.description.startsWith("[CC]"))
{
event.subtitleType |= SUB_NORMAL;
event.description.remove(0,5);
}
if (event.subtitle == "Movie")
{
event.subtitle = QString::null;
event.categoryType = kCategoryMovie;
}
if (event.description.startsWith(event.title))
event.description.remove(0,event.title.length()+1);
}
/** \fn EITFixUp::FixAUSeven(DBEventEIT&) const
* \brief Use this to standardize DVB-T guide in Australia. (Seven network)
*/
void EITFixUp::FixAUSeven(DBEventEIT &event) const
{
if (event.description.endsWith(" Rpt"))
{
event.previouslyshown = true;
event.description.resize(event.description.size()-4);
}
QRegExp year("(\\d{4})$");
if (year.indexIn(event.description) != -1)
{
event.airdate = year.cap(3).toUInt();
event.description.resize(event.description.size()-5);
}
if (event.description.endsWith(" CC"))
{
event.subtitleType |= SUB_NORMAL;
event.description.resize(event.description.size()-3);
}
QString advisories;//store the advisories to append later
QRegExp adv("(\\([A-Z,]+\\))$");
if (adv.indexIn(event.description) != -1)
{
advisories = adv.cap(1);
event.description.resize(event.description.size()-(adv.matchedLength()+1));
}
QRegExp rating("(C|G|PG|M|MA)$");
if (rating.indexIn(event.description) != -1)
{
EventRating prograting;
prograting.system=""; prograting.rating = rating.cap(1);
if (!advisories.isEmpty())
prograting.rating.append(" ").append(advisories);
event.ratings.push_back(prograting);
event.description.resize(event.description.size()-(rating.matchedLength()+1));
}
}
/** \fn EITFixUp::FixAUFreeview(DBEventEIT&) const
* \brief Use this to standardize DVB-T guide in Australia. (generic freeview - extra info in brackets at end of desc)
*/
void EITFixUp::FixAUFreeview(DBEventEIT &event) const
{
if (event.description.endsWith(".."))//has been truncated to fit within the 'subtitle' eit field, so none of the following will work (ABC)
return;
if (m_AUFreeviewSY.indexIn(event.description.trimmed(), 0) != -1)
{
if (event.subtitle.isEmpty())//nine sometimes has an actual subtitle field and the brackets thingo)
event.subtitle = m_AUFreeviewSY.cap(2);
event.airdate = m_AUFreeviewSY.cap(3).toUInt();
event.description = m_AUFreeviewSY.cap(1);
}
else if (m_AUFreeviewY.indexIn(event.description.trimmed(), 0) != -1)
{
event.airdate = m_AUFreeviewY.cap(2).toUInt();
event.description = m_AUFreeviewY.cap(1);
}
else if (m_AUFreeviewSYC.indexIn(event.description.trimmed(), 0) != -1)
{
if (event.subtitle.isEmpty())
event.subtitle = m_AUFreeviewSYC.cap(2);
event.airdate = m_AUFreeviewSYC.cap(3).toUInt();
QStringList actors = m_AUFreeviewSYC.cap(4).split("/");
for (int i = 0; i < actors.size(); ++i)
event.AddPerson(DBPerson::kActor, actors.at(i));
event.description = m_AUFreeviewSYC.cap(1);
}
else if (m_AUFreeviewYC.indexIn(event.description.trimmed(), 0) != -1)
{
event.airdate = m_AUFreeviewYC.cap(2).toUInt();
QStringList actors = m_AUFreeviewYC.cap(3).split("/");
for (int i = 0; i < actors.size(); ++i)
event.AddPerson(DBPerson::kActor, actors.at(i));
event.description = m_AUFreeviewYC.cap(1);
}
}
/** \fn EITFixUp::FixMCA(DBEventEIT&) const
* \brief Use this to standardise the MultiChoice Africa DVB-S guide.
*/
@@ -52,6 +52,11 @@ class EITFixUp
kFixNRK_DVBT = 0x20000,
kFixDish = 0x40000,
kFixDK = 0x80000,
kFixAUFreeview = 0x100000,
kFixAUDescription = 0x200000,
kFixAUNine = 0x400000,
kFixAUSeven = 0x800000,
// Early fixups
kEFixForceISO8859_1 = 0x2000,
@@ -84,6 +89,10 @@ class EITFixUp
void FixComHem(DBEventEIT &event,
bool parse_subtitle) const; // Sweden DVB-C
void FixAUStar(DBEventEIT &event) const; // Australia DVB-S
void FixAUFreeview(DBEventEIT &event) const; // Australia DVB-T
void FixAUNine(DBEventEIT &event) const;
void FixAUSeven(DBEventEIT &event) const;
void FixAUDescription(DBEventEIT &event) const;
void FixMCA(DBEventEIT &event) const; // MultiChoice Africa DVB-S
void FixRTL(DBEventEIT &event) const; // RTL group DVB
void FixFI(DBEventEIT &event) const; // Finland DVB-T
@@ -217,6 +226,10 @@ class EITFixUp
const QRegExp m_dkPersonsSeparator;
const QRegExp m_dkDirector;
const QRegExp m_dkYear;
const QRegExp m_AUFreeviewSY;//subtitle, year
const QRegExp m_AUFreeviewY;//year
const QRegExp m_AUFreeviewYC;//year, cast
const QRegExp m_AUFreeviewSYC;//subtitle, year, cast
};
#endif // EITFIXUP_H
@@ -471,6 +471,59 @@ void EITHelper::AddEIT(const DVBEventInformationTable *eit)
if (EITFixUp::kFixDish & fix)
category = content.GetCategory();
}
else if (EITFixUp::kFixAUDescription & fix)//AU Freeview assigned genres
{
ContentDescriptor content(content_data);
switch (content.Nibble1(0))
{
case 0x01:
category = "Movie";
break;
case 0x02:
category = "News";
break;
case 0x03:
category = "Entertainment";
break;
case 0x04:
category = "Sport";
break;
case 0x05:
category = "Children";
break;
case 0x06:
category = "Music";
break;
case 0x07:
category = "Arts/Culture";
break;
case 0x08:
category = "Current Affairs";
break;
case 0x09:
category = "Education";
break;
case 0x0A:
category = "Infotainment";
break;
case 0x0B:
category = "Special";
break;
case 0x0C:
category = "Comedy";
break;
case 0x0D:
category = "Drama";
break;
case 0x0E:
category = "Documentary";
break;
default:
category = "";
break;
}
category_type = content.GetMythCategory(0);
}
else
{
ContentDescriptor content(content_data);
@@ -492,7 +545,10 @@ void EITHelper::AddEIT(const DVBEventInformationTable *eit)
if (desc.ContentType() == 0x01 || desc.ContentType() == 0x31)
programId = desc.ContentId();
else if (desc.ContentType() == 0x02 || desc.ContentType() == 0x32)
{
seriesId = desc.ContentId();
category_type = kCategorySeries;
}
}
}
@@ -939,8 +995,17 @@ static void init_fixup(QMap<uint64_t,uint> &fix)
fix[40999U << 16 | 1069] = EITFixUp::kFixSubtitle;
// Australia
fix[ 4096U << 16] = EITFixUp::kFixAUStar;
fix[ 4096U << 16] = EITFixUp::kFixAUStar;
fix[ 4096U << 16] = EITFixUp::kFixAUStar;
fix[ 4096U << 16] = EITFixUp::kFixAUStar;
fix[ 4112U << 16] = EITFixUp::kFixAUDescription | EITFixUp::kFixAUFreeview; // ABC Brisbane
fix[ 4114U << 16] = EITFixUp::kFixAUDescription | EITFixUp::kFixAUFreeview | EITFixUp::kFixAUNine;; // Nine Brisbane
fix[ 4115U << 16] = EITFixUp::kFixAUDescription | EITFixUp::kFixAUSeven; //Seven
fix[ 4116U << 16] = EITFixUp::kFixAUDescription; //Ten
fix[ 12801U << 16] = EITFixUp::kFixAUFreeview | EITFixUp::kFixAUDescription; //ABC
fix[ 12802U << 16] = EITFixUp::kFixAUDescription; //SBS
fix[ 12803U << 16] = EITFixUp::kFixAUFreeview | EITFixUp::kFixAUDescription | EITFixUp::kFixAUNine; //Nine
fix[ 12842U << 16] = EITFixUp::kFixAUDescription; // 31 Brisbane
fix[ 12862U << 16] = EITFixUp::kFixAUDescription; //WestTV
// MultiChoice Africa
fix[ 6144U << 16] = EITFixUp::kFixMCA;
@@ -582,6 +582,22 @@ uint DBEvent::UpdateDB(
for (uint i = 0; i < credits->size(); i++)
(*credits)[i].InsertDB(query, chanid, starttime);
}
QList<EventRating>::const_iterator j = ratings.begin();
for (; j != ratings.end(); ++j)
{
query.prepare(
"INSERT INTO programrating "
" ( chanid, starttime, system, rating) "
"VALUES (:CHANID, :START, :SYS, :RATING)");
query.bindValue(":CHANID", chanid);
query.bindValue(":START", starttime);
query.bindValue(":SYS", (*j).system);
query.bindValue(":RATING", (*j).rating);
if (!query.exec())
MythDB::DBError("programrating insert", query);
}
return 1;
}

0 comments on commit 914442c

Please sign in to comment.