updated on Thu Jan 19 16:10:29 UTC 2012
[aur-mirror.git] / mythtv-git / eit.patch
blob08a48ac60d9bb526a7ab405beffde20bb91042ee
1 From 4fee559353de30db76f759704980583dff769ab5 Mon Sep 17 00:00:00 2001
2 From: Miroslav Suchy <miroslav@suchy.cz>
3 Date: Mon, 27 Dec 2010 22:46:17 +0100
4 Subject: [PATCH] Fixes the worst anomalies in the DVB-S/DVB-T EPG for Czech TVs.
6 ---
7 mythtv/libs/libmythtv/eitfixup.cpp | 157 +++++++++++++++++++++++++++++++++++
8 mythtv/libs/libmythtv/eitfixup.h | 12 +++
9 mythtv/libs/libmythtv/eithelper.cpp | 8 ++
10 3 files changed, 177 insertions(+), 0 deletions(-)
12 diff --git a/mythtv/libs/libmythtv/eitfixup.cpp b/mythtv/libs/libmythtv/eitfixup.cpp
13 index 2c4952c..bd8cfd2 100644
14 --- a/mythtv/libs/libmythtv/eitfixup.cpp
15 +++ b/mythtv/libs/libmythtv/eitfixup.cpp
16 @@ -120,6 +120,15 @@ EITFixUp::EITFixUp()
17 "Radioteatret|Opera|P2-Akademiet|Nyhetsmorgen i P2 og Alltid Nyheter:): (.+)"),
18 m_noPremiere("\\s+-\\s+(Sesongpremiere|Premiere)!?$"),
19 - m_Stereo("\\b\\(?[sS]tereo\\)?\\b")
20 + m_Stereo("\\b\\(?[sS]tereo\\)?\\b"),
21 + m_czTitSubTit ("^(.+), ([A-Z].*)$"),
22 + m_czSubSerie ("^(\\d+)/(\\d+) (.*)$"),
23 + m_czTitSerie1 ("^(.+) \\((\\d+)(,\\s?\\d)?\\)$"),
24 + m_czTitSerie2 ("^(.+) \\((\\d+)/(\\d+)\\)$"),
25 + m_czTitSerieRom ("^(.+) ([IVX]+)$"),
26 + m_czTitFlagWide ("^(.+) -W$"),
27 + m_czTitFlagStereo ("^(.+) -ST$"),
28 + m_czTitFlagBW ("^(.+) (cb)$")
33 @@ -183,6 +192,9 @@ void EITFixUp::Fix(DBEventEIT &event) const
34 if (kFixCategory & event.fixup)
35 FixCategory(event);
37 + if (kFixCzechTV & event.fixup)
38 + FixCzechTV(event);
40 if (event.fixup)
42 if (!event.title.isEmpty())
43 @@ -1733,3 +1745,148 @@ void EITFixUp::FixNRK_DVBT(DBEventEIT &event) const
47 +/** \fn EITFixUp::FixCzechTV(DBEventEIT&) const
48 + * \brief Use this to standardize TV in Czech Republic.
49 + */
50 +void EITFixUp::FixCzechTV(DBEventEIT &event) const
52 + QString tmpSubString;
54 + // Czech TV: episode number at the begining of subtitle
55 + QRegExp tmpSub = m_czSubSerie;
56 + if (event.subtitle.isEmpty())
57 + {
58 + // MythTV probably already removed subtitile and has been moved to description
59 + if (tmpSub.indexIn(event.description) != -1)
60 + {
61 + event.partnumber = tmpSub.cap(1).toUInt();
62 + event.parttotal = tmpSub.cap(2).toUInt();
63 + event.description = tmpSub.cap(3);
64 + event.categoryType = kCategorySeries;
65 + }
66 + }
67 + else
68 + {
69 + if (tmpSub.indexIn(event.subtitle) != -1)
70 + {
71 + event.partnumber = tmpSub.cap(1).toUInt();
72 + event.parttotal = tmpSub.cap(2).toUInt();
73 + event.subtitle = tmpSub.cap(3);
74 + event.categoryType = kCategorySeries;
75 + }
76 + }
78 + // Czech TV: in title is mixed name of episode and name of series
79 + // it is coma separated
80 + tmpSub = m_czTitSubTit;
81 + if (tmpSub.indexIn(event.title) != -1)
82 + {
83 + event.title = tmpSub.cap(1);
84 + tmpSubString = tmpSub.cap(2);
85 + if (!event.subtitle.isEmpty())
86 + {
87 + tmpSubString.append(": ");
88 + tmpSubString.append(event.subtitle);
89 + }
90 + event.subtitle = tmpSubString;
91 + }
93 + // Nova+Prima (heuristic according subtitle length):
94 + // subtitle contains first part of description
95 + if (event.subtitle.length() >= 50)
96 + {
97 + tmpSubString = event.subtitle;
98 + tmpSubString.append(" ");
99 + tmpSubString.append(event.description);
100 + event.subtitle = "";
101 + event.description = tmpSubString;
104 + // Nova+Prima: number of episode at the end of title in braces
105 + tmpSub = m_czTitSerie1;
106 + if (tmpSub.indexIn(event.title) != -1)
108 + event.title = tmpSub.cap(1);
109 + event.partnumber = tmpSub.cap(2).toUInt();
110 + event.categoryType = kCategorySeries;
113 + tmpSub = m_czTitSerie2;
114 + if (tmpSub.indexIn(event.title) != -1)
116 + event.title = tmpSub.cap(1);
117 + event.partnumber = tmpSub.cap(2).toUInt();
118 + event.parttotal = tmpSub.cap(3).toUInt();
119 + event.categoryType = kCategorySeries;
122 + if (event.categoryType == kCategorySeries)
124 + // CT, Nova and Prima: romans number of series at the end of title
125 + tmpSub = m_czTitSerieRom;
126 + if (tmpSub.indexIn(event.title) != -1)
128 + event.title = tmpSub.cap(1);
129 + int episode = event.partnumber;
130 + int season = ConvertRomanToArab(tmpSub.cap(2));
131 + event.syndicatedepisodenumber =
132 + QString("E%1S%2").arg(episode).arg(season);
136 + // Nova+Prima: flag of broadcasting in title
137 + tmpSub = m_czTitFlagWide;
138 + if (tmpSub.indexIn(event.title) != -1)
140 + event.title = tmpSub.cap(1);
141 + event.videoProps |= VID_WIDESCREEN;
144 + tmpSub = m_czTitFlagStereo;
145 + if (tmpSub.indexIn(event.title) != -1)
147 + event.title = tmpSub.cap(1);
148 + event.audioProps |= AUD_STEREO;
151 + tmpSub = m_czTitFlagBW;
152 + if (tmpSub.indexIn(event.title) != -1)
154 + event.title = tmpSub.cap(1);
158 +/** \fn EITFixUp::ConvertRomanToArab(QString number) const
159 + * \brief Use this to convert roman numerals to arabic ones.
160 + */
161 +int EITFixUp::ConvertRomanToArab(QString number) const
163 + int res = 0;
164 + int i = 0;
166 + while (i < number.length())
168 + switch(number.at(i).toAscii())
170 + case 'I':
171 + if (i + 1 < number.length())
173 + res += (number[i + 1] == 'I') ? 1 : -1;
175 + else {
176 + res++;
178 + break;
179 + case 'V':
180 + res += 5;
181 + break;
182 + case 'X':
183 + res += 10;
184 + break;
187 + i++;
190 + return res;
192 diff --git a/mythtv/libs/libmythtv/eitfixup.h b/mythtv/libs/libmythtv/eitfixup.h
193 index d4e9cf8..e295e49 100644
194 --- a/mythtv/libs/libmythtv/eitfixup.h
195 +++ b/mythtv/libs/libmythtv/eitfixup.h
196 @@ -51,6 +51,7 @@ class EITFixUp
197 kFixNO = 0x10000,
198 kFixNRK_DVBT = 0x20000,
199 kFixDish = 0x40000,
200 + kFixCzechTV = 0x80000,
202 // Early fixups
203 kEFixForceISO8859_1 = 0x2000,
204 @@ -90,6 +91,8 @@ class EITFixUp
205 void FixCategory(DBEventEIT &event) const; // Generic Category fixes
206 void FixNO(DBEventEIT &event) const; // Norwegian DVB-S
207 void FixNRK_DVBT(DBEventEIT &event) const; // Norwegian NRK DVB-T
208 + void FixCzechTV(DBEventEIT &event) const; // Czech TV
209 + int ConvertRomanToArab(QString number) const;
211 static QString AddDVBEITAuthority(uint chanid, const QString &id);
213 @@ -192,6 +195,15 @@ class EITFixUp
214 const QRegExp m_noNRKCategories;
215 const QRegExp m_noPremiere;
216 const QRegExp m_Stereo;
217 + const QRegExp m_czTitSubTit;
218 + const QRegExp m_czSubSerie;
219 + const QRegExp m_czTitSerie1;
220 + const QRegExp m_czTitSerie2;
221 + const QRegExp m_czTitSerieRom;
222 + const QRegExp m_czTitFlagWide;
223 + const QRegExp m_czTitFlagStereo;
224 + const QRegExp m_czTitFlagBW;
228 #endif // EITFIXUP_H
229 diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp
230 index aa715c5..490592c 100644
231 --- a/mythtv/libs/libmythtv/eithelper.cpp
232 +++ b/mythtv/libs/libmythtv/eithelper.cpp
233 @@ -876,6 +876,14 @@ static void init_fixup(QMap<uint64_t,uint> &fix)
234 fix[910LL << 32 | 8770U << 16 | 0x0455] = EITFixUp::kFixNRK_DVBT; //NRK P1 Tr�delag
235 fix[910LL << 32 | 8770U << 16 | 0x03f1] = EITFixUp::kFixNRK_DVBT; //NRK1 Midtnytt
237 + // Czech Republic
238 + fix[3014LL << 32 | 3 << 16] = EITFixUp::kFixCzechTV; // CT1234 + Prima
239 + fix[3214LL << 32 | 3 << 16] = EITFixUp::kFixCzechTV; // CT HD
240 + fix[3205LL << 32 | 3 << 16] = EITFixUp::kFixCzechTV; // Barrandov
241 + fix[3209LL << 32 | 3 << 16] = EITFixUp::kFixCzechTV; // Prima COOL
242 + fix[3219LL << 32 | 3 << 16] = EITFixUp::kFixCzechTV; // Nova family
243 + fix[3210LL << 32 | 3 << 16] = EITFixUp::kFixCzechTV; // Nova+
245 ///////////////////////////////////////////////////////////////////////////
246 // Special Early fixups for providers that break DVB EIT spec.
247 // transport_id<<32 | network_id<<16 | service_id
249 1.7.2.3