Ticket #13652: eitfixup-ratings-20201721-2.diff

File eitfixup-ratings-20201721-2.diff, 6.2 KB (added by yianniv, 6 years ago)
Line 
1diff --git a/mythtv/libs/libmythtv/eitfixup.cpp b/mythtv/libs/libmythtv/eitfixup.cpp
2index 5d7a668a00..f88d728cb1 100644
3--- a/mythtv/libs/libmythtv/eitfixup.cpp
4+++ b/mythtv/libs/libmythtv/eitfixup.cpp
5@@ -198,6 +198,7 @@ EITFixUp::EITFixUp()
6 m_auFreeviewYC(R"((.*) \(([12][0-9][0-9][0-9])\) \((.+)\)$)"),
7 m_auFreeviewSYC(R"((.*) \((.+)\) \(([12][0-9][0-9][0-9])\) \((.+)\)$)"),
8 m_html("</?EM>", Qt::CaseInsensitive),
9+ m_grRating("(?:(\\[[KΚ](?:(|8|12|16|18)\\]\\s*)))", Qt::CaseInsensitive),
10 m_grReplay("\\([ΕE]\\)"),
11 m_grDescriptionFinale("\\s*΀ελευ
12ταίο\\sΕπεισόΎιο\\.\\s*"),
13 m_grActors("(?:[Ππ]α[ιί]ζου
14Μ:|[ΜMÎŒ]ε του
15ς:|ΠρωταγωΜιστο[υ
16ύ]Μ:|ΠρωταγωΜιστε[ιί]:?)(?:\\s+στο ρόλο(?: του
17| της)?\\s(?:\\w+\\s[οη]\\s))?([-\\w\\s']+(?:,[-\\w\\s']+)*)(?:κ\\.[αά])?(?:\\W?)"),
18@@ -211,7 +212,7 @@ EITFixUp::EITFixUp()
19 m_grCountry("(?:\\W|\\b)(?:(ελληΜ|του
20ρκ|αΌερικ[αά]Μ|γαλλ|αγγλ|βρεττ?αΜ|γερΌαΜ|ρωσσ?|ιταλ|ελβετ|σου
21ηΎ|ισπαΜ|πορτογαλ|ΌεΟικ[αά]Μ|κιΜ[εέ]ζικ|ιαπωΜ|καΜαΎ|βραζιλι[αά]Μ)(ικ[ηή][ςσ]))",Qt::CaseInsensitive),
22 m_grlongEp("\\b(?:Επ.|επεισ[οό]Ύιο:?)\\s*(\\d+)(?:\\W?)",Qt::CaseInsensitive),
23 m_grSeasonAsRomanNumerals(",\\s*([MDCLXVIΙΧ]+)$",Qt::CaseInsensitive),
24- m_grSeason("(?:\\W-?)*(?:\\(-\\s*)?\\b(([Α-Ω]{1,2})(?:'|΄)?|(\\d{1,2})(?:ος|ου
25|oς|os)?)(?:\\s*κ[υ
26ύ]κλο(?:[σς]|υ
27)){1}\\s?",Qt::CaseInsensitive),
28+ m_grSeason("(?:\\W-?)*(?:\\(-\\s*)?\\b(([Α-Ω|A|B|E|Z|H|I|K|M|N]{1,2})(?:'|΄)?|(\\d{1,2})(?:ος|ου
29|oς|os)?)(?:\\s*[ΚκKk][υ
30ύ]κλο(?:[σς]|υ
31)){1}\\s?",Qt::CaseInsensitive),
32 m_grRealTitleinDescription(R"((?:^\()([A-Za-z\s\d-]+)(?:\))(?:\s*))"),
33 // cap1 = real title
34 // cap0 = real title in parentheses.
35@@ -2601,9 +2602,23 @@ void EITFixUp::FixGreekSubtitle(DBEventEIT &event)
36
37 void EITFixUp::FixGreekEIT(DBEventEIT &event) const
38 {
39- //Live show
40+
41+ int position;
42 QRegExp tmpRegEx;
43- int position = event.m_title.indexOf("(Ζ)");
44+
45+ // Program ratings
46+ tmpRegEx = m_grRating;
47+ position = event.m_title.indexOf(tmpRegEx);
48+ if (position != -1)
49+ {
50+ EventRating prograting;
51+ prograting.m_system="GR"; prograting.m_rating = tmpRegEx.cap(1);
52+ event.m_ratings.push_back(prograting);
53+ event.m_title = event.m_title.replace(tmpRegEx.cap(1), "").trimmed();
54+ }
55+
56+ //Live show
57+ position = event.m_title.indexOf("(Ζ)");
58 if (position != -1)
59 {
60 event.m_title = event.m_title.replace("(Ζ)", "");
61@@ -2773,8 +2788,49 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event) const
62 // cap(2) is the season for ΑΒΓΔ
63 // cap(3) is the season for 1234
64 int position1 = tmpSeries.indexIn(event.m_title);
65+ if (position1 != -1)
66+ {
67+ if (!tmpSeries.cap(2).isEmpty()) // we found a letter representing a number
68+ {
69+ //sometimes Nat. TV writes numbers as letters, i.e Α=1, Β=2, Γ=3, etc
70+ //must convert them to numbers.
71+ int tmpinteger = tmpSeries.cap(2).toUInt();
72+ if (tmpinteger < 1)
73+ {
74+ if (tmpSeries.cap(2) == "Σ΀") // 6, don't ask!
75+ event.m_season = 6;
76+ else
77+ {
78+ QString LettToNumber = "0ΑΒΓΔΕ6ΖΗΘΙΚΛΜΝ";
79+ tmpinteger = LettToNumber.indexOf(tmpSeries.cap(2));
80+ if (tmpinteger != -1)
81+ event.m_season = tmpinteger;
82+ else
83+ //sometimes they use english letters instead of greek. Compensating:
84+ {
85+ LettToNumber = "0ABΓΔE6ZHΘIKΛMN";
86+ tmpinteger = LettToNumber.indexOf(tmpSeries.cap(2));
87+ if (tmpinteger != -1)
88+ event.m_season = tmpinteger;
89+ }
90+ }
91+ }
92+ }
93+ else if (!tmpSeries.cap(3).isEmpty()) //number
94+ {
95+ event.m_season = tmpSeries.cap(3).toUInt();
96+ }
97+ series = true;
98+ event.m_title.replace(tmpSeries.cap(0),"");
99+ }
100+
101+ // I have to search separately for season in title and description because it wouldn't work when in both.
102+ series = false;
103+ tmpSeries = m_grSeason;
104+ // cap(2) is the season for ΑΒΓΔ
105+ // cap(3) is the season for 1234
106 int position2 = tmpSeries.indexIn(event.m_description);
107- if ((position1 != -1) || (position2 != -1))
108+ if (position2 != -1)
109 {
110 if (!tmpSeries.cap(2).isEmpty()) // we found a letter representing a number
111 {
112@@ -2799,11 +2855,10 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event) const
113 event.m_season = tmpSeries.cap(3).toUInt();
114 }
115 series = true;
116- if (position1 != -1)
117- event.m_title.replace(tmpSeries.cap(0),"");
118- if (position2 != -1)
119- event.m_description.replace(tmpSeries.cap(0),"");
120+ event.m_description.replace(tmpSeries.cap(0),"");
121 }
122+
123+
124 // If Season is in Roman Numerals (I,II,etc)
125 tmpSeries = m_grSeasonAsRomanNumerals;
126 if ((position1 = tmpSeries.indexIn(event.m_title)) != -1
127@@ -2954,6 +3009,8 @@ void EITFixUp::FixGreekEIT(DBEventEIT &event) const
128 {
129 event.m_categoryType = ProgramInfo::kCategorySeries;
130 }
131+ // clear double commas.
132+ event.m_description.replace(",,", ",");
133 // just for luck, retrim fields.
134 event.m_description = event.m_description.trimmed();
135 event.m_title = event.m_title.trimmed();
136diff --git a/mythtv/libs/libmythtv/eitfixup.h b/mythtv/libs/libmythtv/eitfixup.h
137index 6dbc10784a..6cc7068172 100644
138--- a/mythtv/libs/libmythtv/eitfixup.h
139+++ b/mythtv/libs/libmythtv/eitfixup.h
140@@ -263,6 +263,7 @@ class MTV_PUBLIC EITFixUp
141 const QRegExp m_auFreeviewYC;//year, cast
142 const QRegExp m_auFreeviewSYC;//subtitle, year, cast
143 const QRegExp m_html;
144+ const QRegExp m_grRating; // Greek new parental rating system
145 const QRegExp m_grReplay; //Greek rerun
146 const QRegExp m_grDescriptionFinale; //Greek last m_grEpisode
147 const QRegExp m_grActors; //Greek actors