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

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