[PATCH] Fixes the worst anomalies in the DVB-S/DVB-T EPG for Czech TVs.

Miroslav Suchy miroslav at suchy.cz
Mon Dec 27 21:46:17 UTC 2010


---
 mythtv/libs/libmythtv/eitfixup.cpp  |  157 +++++++++++++++++++++++++++++++++++
 mythtv/libs/libmythtv/eitfixup.h    |   12 +++
 mythtv/libs/libmythtv/eithelper.cpp |    8 ++
 3 files changed, 177 insertions(+), 0 deletions(-)

diff --git a/mythtv/libs/libmythtv/eitfixup.cpp b/mythtv/libs/libmythtv/eitfixup.cpp
index 2c4952c..bd8cfd2 100644
--- a/mythtv/libs/libmythtv/eitfixup.cpp
+++ b/mythtv/libs/libmythtv/eitfixup.cpp
@@ -120,6 +120,15 @@ EITFixUp::EITFixUp()
                         "Radioteatret|Opera|P2-Akademiet|Nyhetsmorgen i P2 og Alltid Nyheter:): (.+)"),
       m_noPremiere("\\s+-\\s+(Sesongpremiere|Premiere)!?$"),
       m_Stereo("\\b\\(?[sS]tereo\\)?\\b")
+      m_nlOmroep ("\\s\\(([A-Z]+/?)+\\)$"),
+      m_czTitSubTit ("^(.+), ([A-Z].*)$"),
+      m_czSubSerie ("^(\\d+)/(\\d+) (.*)$"),
+      m_czTitSerie1 ("^(.+) \\((\\d+)(,\\s?\\d)?\\)$"),
+      m_czTitSerie2 ("^(.+) \\((\\d+)/(\\d+)\\)$"),
+      m_czTitSerieRom ("^(.+) ([IVX]+)$"),
+      m_czTitFlagWide ("^(.+) -W$"),
+      m_czTitFlagStereo ("^(.+) -ST$"),
+      m_czTitFlagBW ("^(.+) (cb)$")
 
 {
 }
@@ -183,6 +192,9 @@ void EITFixUp::Fix(DBEventEIT &event) const
     if (kFixCategory & event.fixup)
         FixCategory(event);
 
+    if (kFixCzechTV & event.fixup)
+        FixCzechTV(event);
+
     if (event.fixup)
     {
         if (!event.title.isEmpty())
@@ -1733,3 +1745,148 @@ void EITFixUp::FixNRK_DVBT(DBEventEIT &event) const
     }
 }
 
+/** \fn EITFixUp::FixCzechTV(DBEventEIT&) const
+ *  \brief Use this to standardize TV in Czech Republic.
+ */
+void EITFixUp::FixCzechTV(DBEventEIT &event) const
+{
+    QString tmpSubString;
+
+    // Czech TV: episode number at the begining of subtitle
+    QRegExp tmpSub = m_czSubSerie;
+    if (event.subtitle.isEmpty())
+    {
+        // MythTV probably already removed subtitile and has been moved to description
+        if (tmpSub.indexIn(event.description) != -1)
+        {
+            event.partnumber = tmpSub.cap(1).toUInt();
+            event.parttotal  = tmpSub.cap(2).toUInt();
+            event.description = tmpSub.cap(3);
+            event.categoryType = kCategorySeries;
+        }
+    }
+    else
+    {
+        if (tmpSub.indexIn(event.subtitle) != -1)
+        {
+            event.partnumber = tmpSub.cap(1).toUInt();
+            event.parttotal  = tmpSub.cap(2).toUInt();
+            event.subtitle = tmpSub.cap(3);
+            event.categoryType = kCategorySeries;
+        }
+    }
+
+    // Czech TV: in title is mixed name of episode and name of series
+    // it is coma separated
+    tmpSub = m_czTitSubTit;
+    if (tmpSub.indexIn(event.title) != -1)
+    {
+        event.title = tmpSub.cap(1);
+        tmpSubString = tmpSub.cap(2);
+        if (!event.subtitle.isEmpty())
+        {
+            tmpSubString.append(": ");
+            tmpSubString.append(event.subtitle);
+        }
+        event.subtitle = tmpSubString;
+    }
+
+    // Nova+Prima (heuristic according subtitle length):
+    // subtitle contains first part of description
+    if (event.subtitle.length() >= 50)
+    {
+        tmpSubString = event.subtitle;
+        tmpSubString.append(" ");
+        tmpSubString.append(event.description);
+        event.subtitle = "";
+        event.description = tmpSubString;
+    }
+
+    // Nova+Prima: number of episode at the end of title in braces
+    tmpSub = m_czTitSerie1;
+    if (tmpSub.indexIn(event.title) != -1)
+    {
+        event.title = tmpSub.cap(1);
+        event.partnumber = tmpSub.cap(2).toUInt();
+        event.categoryType = kCategorySeries;
+    }
+
+    tmpSub = m_czTitSerie2;
+    if (tmpSub.indexIn(event.title) != -1)
+    {
+        event.title = tmpSub.cap(1);
+        event.partnumber = tmpSub.cap(2).toUInt();
+        event.parttotal  = tmpSub.cap(3).toUInt();
+        event.categoryType = kCategorySeries;
+    }
+
+    if (event.categoryType == kCategorySeries)
+    {
+        // CT, Nova and Prima: romans number of series at the end of title
+        tmpSub = m_czTitSerieRom;
+        if (tmpSub.indexIn(event.title) != -1)
+        {
+            event.title = tmpSub.cap(1);
+            int episode = event.partnumber;
+            int season = ConvertRomanToArab(tmpSub.cap(2));
+            event.syndicatedepisodenumber =
+                QString("E%1S%2").arg(episode).arg(season);
+        }
+    }
+
+    // Nova+Prima: flag of broadcasting in title
+    tmpSub = m_czTitFlagWide;
+    if (tmpSub.indexIn(event.title) != -1)
+    {
+        event.title = tmpSub.cap(1);
+        event.videoProps |= VID_WIDESCREEN;
+    }
+
+    tmpSub = m_czTitFlagStereo;
+    if (tmpSub.indexIn(event.title) != -1)
+    {
+        event.title = tmpSub.cap(1);
+        event.audioProps |= AUD_STEREO;
+    }
+
+    tmpSub = m_czTitFlagBW;
+    if (tmpSub.indexIn(event.title) != -1)
+    {
+        event.title = tmpSub.cap(1);
+    }
+}
+
+/** \fn EITFixUp::ConvertRomanToArab(QString number) const
+ *  \brief Use this to convert roman numerals to arabic ones.
+ */
+int EITFixUp::ConvertRomanToArab(QString number) const
+{
+    int res = 0;
+    int i = 0;
+
+    while (i < number.length())
+    {
+        switch(number.at(i).toAscii())
+        {
+            case 'I':
+                if (i + 1 < number.length())
+                {
+                    res += (number[i + 1] == 'I') ? 1 : -1;
+                }
+                else {
+                    res++;
+                }
+                break;
+            case 'V':
+                res += 5;
+                break;
+            case 'X':
+                res += 10;
+                break;
+        }
+
+        i++;
+    }
+
+    return res;
+}
diff --git a/mythtv/libs/libmythtv/eitfixup.h b/mythtv/libs/libmythtv/eitfixup.h
index d4e9cf8..e295e49 100644
--- a/mythtv/libs/libmythtv/eitfixup.h
+++ b/mythtv/libs/libmythtv/eitfixup.h
@@ -51,6 +51,7 @@ class EITFixUp
         kFixNO         = 0x10000,
         kFixNRK_DVBT   = 0x20000,
         kFixDish       = 0x40000,
+        kFixCzechTV    = 0x80000,
 
         // Early fixups
         kEFixForceISO8859_1  = 0x2000,
@@ -90,6 +91,8 @@ class EITFixUp
     void FixCategory(DBEventEIT &event) const;      // Generic Category fixes
     void FixNO(DBEventEIT &event) const;            // Norwegian DVB-S
     void FixNRK_DVBT(DBEventEIT &event) const;      // Norwegian NRK DVB-T
+    void FixCzechTV(DBEventEIT &event) const;       // Czech TV
+    int ConvertRomanToArab(QString number) const;
 
     static QString AddDVBEITAuthority(uint chanid, const QString &id);
 
@@ -192,6 +195,15 @@ class EITFixUp
     const QRegExp m_noNRKCategories;
     const QRegExp m_noPremiere;
     const QRegExp m_Stereo;
+    const QRegExp m_czTitSubTit;
+    const QRegExp m_czSubSerie;
+    const QRegExp m_czTitSerie1;
+    const QRegExp m_czTitSerie2;
+    const QRegExp m_czTitSerieRom;
+    const QRegExp m_czTitFlagWide;
+    const QRegExp m_czTitFlagStereo;
+    const QRegExp m_czTitFlagBW;
+
 };
 
 #endif // EITFIXUP_H
diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp
index aa715c5..490592c 100644
--- a/mythtv/libs/libmythtv/eithelper.cpp
+++ b/mythtv/libs/libmythtv/eithelper.cpp
@@ -876,6 +876,14 @@ static void init_fixup(QMap<uint64_t,uint> &fix)
     fix[910LL << 32 | 8770U  << 16 | 0x0455] = EITFixUp::kFixNRK_DVBT;  //NRK P1 Tr�delag
     fix[910LL << 32 | 8770U  << 16 | 0x03f1] = EITFixUp::kFixNRK_DVBT;  //NRK1 Midtnytt
 
+    // Czech Republic
+    fix[3014LL << 32 |    3 << 16] = EITFixUp::kFixCzechTV; // CT1234 + Prima
+    fix[3214LL << 32 |    3 << 16] = EITFixUp::kFixCzechTV; // CT HD
+    fix[3205LL << 32 |    3 << 16] = EITFixUp::kFixCzechTV; // Barrandov
+    fix[3209LL << 32 |    3 << 16] = EITFixUp::kFixCzechTV; // Prima COOL
+    fix[3219LL << 32 |    3 << 16] = EITFixUp::kFixCzechTV; // Nova family
+
+
     ///////////////////////////////////////////////////////////////////////////
     // Special Early fixups for providers that break DVB EIT spec.
     // transport_id<<32 | network_id<<16 | service_id
-- 
1.7.2.3


--------------050106020100050406030108--


More information about the mythtv-dev mailing list