-
Notifications
You must be signed in to change notification settings - Fork 341
/
eitfixup.cpp
1998 lines (1816 loc) · 66.4 KB
/
eitfixup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// C++ headers
#include <algorithm>
// MythTV headers
#include "eitfixup.h"
#include "dvbdescriptors.h" // for MythCategoryType
#include "channelutil.h" // for GetDefaultAuthority()
#include "programinfo.h" // for subtitle types and audio and video properties
#include "dishdescriptors.h" // for dish_theme_type_to_string
/*------------------------------------------------------------------------
* Event Fix Up Scripts - Turned on by entry in dtv_privatetype table
*------------------------------------------------------------------------*/
EITFixUp::EITFixUp()
: m_bellYear("[\\(]{1}[0-9]{4}[\\)]{1}"),
m_bellActors("\\set\\s|,"),
m_bellPPVTitleAllDayHD("\\s*\\(All Day\\, HD\\)\\s*$"),
m_bellPPVTitleAllDay("\\s*\\(All Day.*\\)\\s*$"),
m_bellPPVTitleHD("^HD\\s?-\\s?"),
m_bellPPVSubtitleAllDay("^All Day \\(.*\\sEastern\\)\\s*$"),
m_bellPPVDescriptionAllDay("^\\(.*\\sEastern\\)"),
m_bellPPVDescriptionAllDay2("^\\([0-9].*am-[0-9].*am\\sET\\)"),
m_bellPPVDescriptionEventId("\\([0-9]{5}\\)"),
m_dishPPVTitleHD("\\sHD\\s*$"),
m_dishPPVTitleColon("\\:\\s*$"),
m_dishPPVSpacePerenEnd("\\s\\)\\s*$"),
m_dishDescriptionNew("\\s*New\\.\\s*"),
m_dishDescriptionFinale("\\s*(Series|Season)\\sFinale\\.\\s*"),
m_dishDescriptionFinale2("\\s*Finale\\.\\s*"),
m_dishDescriptionPremiere("\\s*(Series|Season)\\s(Premier|Premiere)\\.\\s*"),
m_dishDescriptionPremiere2("\\s*(Premier|Premiere)\\.\\s*"),
m_dishPPVCode("\\s*\\(([A-Z]|[0-9]){5}\\)\\s*$"),
m_ukThen("\\s*(Then|Followed by) 60 Seconds\\.", Qt::CaseInsensitive),
m_ukNew("(New\\.|\\s*(Brand New|New)\\s*(Series|Episode)\\s*[:\\.\\-])",Qt::CaseInsensitive),
m_ukCEPQ("[:\\!\\.\\?]"),
m_ukColonPeriod("[:\\.]"),
m_ukDotSpaceStart("^\\. "),
m_ukDotEnd("\\.$"),
m_ukSpaceColonStart("^[ |:]*"),
m_ukSpaceStart("^ "),
m_ukSeries("\\s*\\(?\\s*(?:Episode|Part|Pt)?\\s*(\\d{1,2})\\s*(?:of|/)\\s*(\\d{1,2})\\s*\\)?\\s*(?:\\.|:)?", Qt::CaseInsensitive),
m_ukCC("\\[(?:(AD|SL|S|W),?)+\\]"),
m_ukYear("[\\[\\(]([\\d]{4})[\\)\\]]"),
m_uk24ep("^\\d{1,2}:00[ap]m to \\d{1,2}:00[ap]m: "),
m_ukStarring("(?:Western\\s)?[Ss]tarring ([\\w\\s\\-']+)[Aa]nd\\s([\\w\\s\\-']+)[\\.|,](?:\\s)*(\\d{4})?(?:\\.\\s)?"),
m_ukBBC7rpt("\\[Rptd?[^]]+\\d{1,2}\\.\\d{1,2}[ap]m\\]\\."),
m_ukDescriptionRemove("^(?:CBBC\\s*\\.|CBeebies\\s*\\.|Class TV\\s*:|BBC Switch\\.)"),
m_ukTitleRemove("^(?:[tT]4:|Schools\\s*:)"),
m_ukDoubleDotEnd("\\.\\.+$"),
m_ukDoubleDotStart("^\\.\\.+"),
m_ukTime("\\d{1,2}[\\.:]\\d{1,2}\\s*(am|pm|)"),
m_ukBBC34("BBC (?:THREE|FOUR) on BBC (?:ONE|TWO)\\.",Qt::CaseInsensitive),
m_ukYearColon("^[\\d]{4}:"),
m_ukExclusionFromSubtitle("(starring|stars\\s|drama|series|sitcom)",Qt::CaseInsensitive),
m_ukCompleteDots("^\\.\\.+$"),
m_ukQuotedSubtitle("(?:^')([\\w\\s\\-,]+)(?:\\.' )"),
m_ukAllNew("All New To 4Music!\\s?"),
m_comHemCountry("^(\\(.+\\))?\\s?([^ ]+)\\s([^\\.0-9]+)"
"(?:\\sfrån\\s([0-9]{4}))(?:\\smed\\s([^\\.]+))?\\.?"),
m_comHemDirector("[Rr]egi"),
m_comHemActor("[Ss]kådespelare|[Ii] rollerna"),
m_comHemHost("[Pp]rogramledare"),
m_comHemSub("[.\\?\\!] "),
m_comHemRerun1("[Rr]epris\\sfrån\\s([^\\.]+)(?:\\.|$)"),
m_comHemRerun2("([0-9]+)/([0-9]+)(?:\\s-\\s([0-9]{4}))?"),
m_comHemTT("[Tt]ext-[Tt][Vv]"),
m_comHemPersSeparator("(, |\\soch\\s)"),
m_comHemPersons("\\s?([Rr]egi|[Ss]kådespelare|[Pp]rogramledare|"
"[Ii] rollerna):\\s([^\\.]+)\\."),
m_comHemSubEnd("\\s?\\.\\s?$"),
m_comHemSeries1("\\s?(?:[dD]el|[eE]pisode)\\s([0-9]+)"
"(?:\\s?(?:/|:|av)\\s?([0-9]+))?\\."),
m_comHemSeries2("\\s?-?\\s?([Dd]el\\s+([0-9]+))"),
m_comHemTSub("\\s+-\\s+([^\\-]+)"),
m_mcaIncompleteTitle("(.*).\\.\\.\\.$"),
m_mcaCompleteTitlea("^'?("),
m_mcaCompleteTitleb("[^\\.\\?]+[^\\'])'?[\\.\\?]\\s+(.+)"),
m_mcaSubtitle("^'([^\\.]+)'\\.\\s+(.+)"),
m_mcaSeries("^S?(\\d+)\\/E?(\\d+)\\s-\\s(.*)$"),
m_mcaCredits("(.*)\\s\\((\\d{4})\\)\\s*([^\\.]+)\\.?\\s*$"),
m_mcaAvail("\\s(Only available on [^\\.]*bouquet|Not available in RSA [^\\.]*)\\.?"),
m_mcaActors("(.*\\.)\\s+([^\\.]+\\s[A-Z][^\\.]+)\\.\\s*"),
m_mcaActorsSeparator("(,\\s+)"),
m_mcaYear("(.*)\\s\\((\\d{4})\\)\\s*$"),
m_mcaCC(",?\\s(HI|English) Subtitles\\.?"),
m_mcaDD(",?\\sDD\\.?"),
m_RTLrepeat("(\\(|\\s)?Wiederholung.+vo[m|n].+((?:\\d{2}\\.\\d{2}\\.\\d{4})|(?:\\d{2}[:\\.]\\d{2}\\sUhr))\\)?"),
m_RTLSubtitle("^([^\\.]{3,})\\.\\s+(.+)"),
/* should be (?:\x{8a}|\\.\\s*|$) but 0x8A gets replaced with 0x20 */
m_RTLSubtitle1("^Folge\\s(\\d{1,4})\\s*:\\s+'(.*)'(?:\\s|\\.\\s*|$)"),
m_RTLSubtitle2("^Folge\\s(\\d{1,4})\\s+(.{,5}[^\\.]{,120})[\\?!\\.]\\s*"),
m_RTLSubtitle3("^(?:Folge\\s)?(\\d{1,4}(?:\\/[IVX]+)?)\\s+(.{,5}[^\\.]{,120})[\\?!\\.]\\s*"),
m_RTLSubtitle4("^Thema.{0,5}:\\s([^\\.]+)\\.\\s*"),
m_RTLSubtitle5("^'(.+)'\\.\\s*"),
m_RTLEpisodeNo1("^(Folge\\s\\d{1,4})\\.*\\s*"),
m_RTLEpisodeNo2("^(\\d{1,2}\\/[IVX]+)\\.*\\s*"),
m_fiRerun("\\ ?Uusinta[a-zA-Z\\ ]*\\.?"),
m_fiRerun2("\\([Uu]\\)"),
m_dePremiereInfos("([^.]+)?\\s?([0-9]{4})\\.\\s[0-9]+\\sMin\\.(?:\\sVon"
"\\s([^,]+)(?:,|\\su\\.\\sa\\.)\\smit\\s(.+)\\.)?"),
m_dePremiereOTitle("\\s*\\(([^\\)]*)\\)$"),
m_nlTxt("txt"),
m_nlWide("breedbeeld"),
m_nlRepeat("herh."),
m_nlHD("\\sHD$"),
m_nlSub("\\sAfl\\.:\\s([^\\.]+)\\."),
m_nlActors("\\sMet:\\s.+e\\.a\\."),
m_nlPres("\\sPresentatie:\\s([^\\.]+)\\."),
m_nlPersSeparator("(, |\\sen\\s)"),
m_nlRub("\\s?\\({1}\\W+\\){1}\\s?"),
m_nlYear1("(?=\\suit\\s)([1-2]{2}[0-9]{2})"),
m_nlYear2("([\\s]{1}[\\(]{1}[A-Z]{0,3}/?)([1-2]{2}[0-9]{2})([\\)]{1})"),
m_nlDirector("(?=\\svan\\s)(([A-Z]{1}[a-z]+\\s)|([A-Z]{1}\\.\\s))"),
m_nlCat("^(Amusement|Muziek|Informatief|Nieuws/actualiteiten|Jeugd|Animatie|Sport|Serie/soap|Kunst/Cultuur|Documentaire|Film|Natuur|Erotiek|Comedy|Misdaad|Religieus)\\.\\s"),
m_nlOmroep ("\\s\\(([A-Z]+/?)+\\)$"),
m_noRerun("\\(R\\)"),
m_noHD("[\\(\\[]HD[\\)\\]]"),
m_noColonSubtitle("^([^:]+): (.+)"),
m_noNRKCategories("^(Superstrek[ea]r|Supersomm[ea]r|Superjul|Barne-tv|Fantorangen|Kuraffen|Supermorg[eo]n|Julemorg[eo]n|Sommermorg[eo]n|"
"Kuraffen-TV|Sport i dag|NRKs sportsl.rdag|NRKs sportss.ndag|Dagens dokumentar|"
"NRK2s historiekveld|Detektimen|Nattkino|Filmklassiker|Film|Kortfilm|P.skemorg[eo]n|"
"Radioteatret|Opera|P2-Akademiet|Nyhetsmorg[eo]n i P2 og Alltid Nyheter:): (.+)"),
m_noPremiere("\\s+-\\s+(Sesongpremiere|Premiere|premiere)!?$"),
m_Stereo("\\b\\(?[sS]tereo\\)?\\b"),
m_dkEpisode("\\(([0-9]+)\\)"),
m_dkPart("\\(([0-9]+):([0-9]+)\\)"),
m_dkSubtitle1("^([^:]+): (.+)"),
m_dkSubtitle2("^([^:]+) - (.+)"),
m_dkSeason1("Sæson ([0-9]+)\\."),
m_dkSeason2("- år ([0-9]+)(?: :)"),
m_dkFeatures("Features:(.+)"),
m_dkWidescreen(" 16:9"),
m_dkDolby(" 5:1"),
m_dkSurround(" \\(\\(S\\)\\)"),
m_dkStereo(" S"),
m_dkReplay(" \\(G\\)"),
m_dkTxt(" TTV"),
m_dkHD(" HD"),
m_dkActors("(?:Medvirkende: |Medv\\.: )(.+)"),
m_dkPersonsSeparator("(, )|(og )"),
m_dkDirector("(?:Instr.: |Instrukt.r: )(.+)$"),
m_dkYear(" fra ([0-9]{4})[ \\.]")
{
}
void EITFixUp::Fix(DBEventEIT &event) const
{
if (event.fixup)
{
if (event.subtitle == event.title)
event.subtitle = QString("");
if (event.description.isEmpty() && !event.subtitle.isEmpty())
{
event.description = event.subtitle;
event.subtitle = QString("");
}
}
if (kFixHDTV & event.fixup)
event.videoProps |= VID_HDTV;
if (kFixBell & event.fixup)
FixBellExpressVu(event);
if (kFixDish & event.fixup)
FixBellExpressVu(event);
if (kFixUK & event.fixup)
FixUK(event);
if (kFixPBS & event.fixup)
FixPBS(event);
if (kFixComHem & event.fixup)
FixComHem(event, kFixSubtitle & event.fixup);
if (kFixAUStar & event.fixup)
FixAUStar(event);
if (kFixMCA & event.fixup)
FixMCA(event);
if (kFixRTL & event.fixup)
FixRTL(event);
if (kFixFI & event.fixup)
FixFI(event);
if (kFixPremiere & event.fixup)
FixPremiere(event);
if (kFixNL & event.fixup)
FixNL(event);
if (kFixNO & event.fixup)
FixNO(event);
if (kFixNRK_DVBT & event.fixup)
FixNRK_DVBT(event);
if (kFixDK & event.fixup)
FixDK(event);
if (kFixCategory & event.fixup)
FixCategory(event);
if (event.fixup)
{
if (!event.title.isEmpty())
{
event.title = event.title.replace(QChar('\0'), "");
event.title = event.title.trimmed();
}
if (!event.subtitle.isEmpty())
{
event.subtitle = event.subtitle.replace(QChar('\0'), "");
event.subtitle = event.subtitle.trimmed();
}
if (!event.description.isEmpty())
{
event.description = event.description.replace(QChar('\0'), "");
event.description = event.description.trimmed();
}
}
if (kFixGenericDVB & event.fixup)
{
event.programId = AddDVBEITAuthority(event.chanid, event.programId);
event.seriesId = AddDVBEITAuthority(event.chanid, event.seriesId);
}
}
/**
* This adds a DVB EIT default authority to series id or program id if
* one exists in the DB for that channel, otherwise it returns a blank
* id instead of the id passed in.
*
* If a series id or program id is a CRID URI, just keep important info
* ID's are case insensitive, so lower case the whole id.
* If there is no authority on the ID, add the default one.
* If there is no default, return an empty id.
*
* \param id The ID string to add the authority to.
* \param query Object to use for SQL queries.
*
* \return ID with the authority added or empty string if not a valid CRID.
*/
QString EITFixUp::AddDVBEITAuthority(uint chanid, const QString &id)
{
if (id.isEmpty())
return id;
// CRIDs are not case sensitive, so change all to lower case
QString crid = id.toLower();
// remove "crid://"
if (crid.startsWith("crid://"))
crid.remove(0,7);
// if id is a CRID with authority, return it
if (crid.length() >= 1 && crid[0] != '/')
return crid;
QString authority = ChannelUtil::GetDefaultAuthority(chanid);
if (authority.isEmpty())
return ""; // no authority, not a valid CRID, return empty
return authority + crid;
}
/**
* \brief Use this for the Canadian BellExpressVu to standardize DVB-S guide.
* \todo deal with events that don't have eventype at the begining?
* \TODO
*/
void EITFixUp::FixBellExpressVu(DBEventEIT &event) const
{
QString tmp;
// A 0x0D character is present between the content
// and the subtitle if its present
int position = event.description.indexOf(0x0D);
if (position != -1)
{
// Subtitle present in the title, so get
// it and adjust the description
event.subtitle = event.description.left(position);
event.description = event.description.right(
event.description.length() - position - 2);
}
// Take out the content description which is
// always next with a period after it
position = event.description.indexOf(".");
// Make sure they didn't leave it out and
// you come up with an odd category
if (position < 10)
{
}
else
{
event.category = "Unknown";
}
// If the content descriptor didn't come up with anything, try parsing the category
// out of the description.
if (event.category.isEmpty())
{
// Take out the content description which is
// always next with a period after it
position = event.description.indexOf(".");
if ((position + 1) < event.description.length())
position = event.description.indexOf(". ");
// Make sure they didn't leave it out and
// you come up with an odd category
if ((position > -1) && position < 20)
{
const QString stmp = event.description;
event.description = stmp.right(stmp.length() - position - 2);
event.category = stmp.left(position);
int position_p = event.category.indexOf("(");
if (position_p == -1)
event.description = stmp.right(stmp.length() - position - 2);
else
event.category = "Unknown";
}
else
{
event.category = "Unknown";
}
// When a channel is off air the category is "-"
// so leave the category as blank
if (event.category == "-")
event.category = "OffAir";
if (event.category.length() > 20)
event.category = "Unknown";
}
else if (event.categoryType)
{
QString theme = dish_theme_type_to_string(event.categoryType);
event.description = event.description.replace(theme, "");
if (event.description.startsWith("."))
event.description = event.description.right(event.description.length() - 1);
if (event.description.startsWith(" "))
event.description = event.description.right(event.description.length() - 1);
}
// See if a year is present as (xxxx)
position = event.description.indexOf(m_bellYear);
if (position != -1 && !event.category.isEmpty())
{
tmp = "";
// Parse out the year
bool ok;
uint y = event.description.mid(position + 1, 4).toUInt(&ok);
if (ok)
{
event.originalairdate = QDate(y, 1, 1);
event.airdate = y;
event.previouslyshown = true;
}
// Get the actors if they exist
if (position > 3)
{
tmp = event.description.left(position-3);
QStringList actors =
tmp.split(m_bellActors, QString::SkipEmptyParts);
QStringList::const_iterator it = actors.begin();
for (; it != actors.end(); ++it)
event.AddPerson(DBPerson::kActor, *it);
}
// Remove the year and actors from the description
event.description = event.description.right(
event.description.length() - position - 7);
}
// Check for (CC) in the decription and
// set the <subtitles type="teletext"> flag
position = event.description.indexOf("(CC)");
if (position != -1)
{
event.subtitleType |= SUB_HARDHEAR;
event.description = event.description.replace("(CC)", "");
}
// Check for (Stereo) in the decription and set the <audio> tags
position = event.description.indexOf(m_Stereo);
if (position != -1)
{
event.audioProps |= AUD_STEREO;
event.description = event.description.replace(m_Stereo, "");
}
// Check for "title (All Day, HD)" in the title
position = event.title.indexOf(m_bellPPVTitleAllDayHD);
if (position != -1)
{
event.title = event.title.replace(m_bellPPVTitleAllDayHD, "");
event.videoProps |= VID_HDTV;
}
// Check for "title (All Day)" in the title
position = event.title.indexOf(m_bellPPVTitleAllDay);
if (position != -1)
{
event.title = event.title.replace(m_bellPPVTitleAllDay, "");
}
// Check for "HD - title" in the title
position = event.title.indexOf(m_bellPPVTitleHD);
if (position != -1)
{
event.title = event.title.replace(m_bellPPVTitleHD, "");
event.videoProps |= VID_HDTV;
}
// Check for (HD) in the decription
position = event.description.indexOf("(HD)");
if (position != -1)
{
event.description = event.description.replace("(HD)", "");
event.videoProps |= VID_HDTV;
}
// Check for (HD) in the title
position = event.title.indexOf("(HD)");
if (position != -1)
{
event.description = event.title.replace("(HD)", "");
event.videoProps |= VID_HDTV;
}
// Check for HD at the end of the title
position = event.title.indexOf(m_dishPPVTitleHD);
if (position != -1)
{
event.title = event.title.replace(m_dishPPVTitleHD, "");
event.videoProps |= VID_HDTV;
}
// Check for (DD) at the end of the description
position = event.description.indexOf("(DD)");
if (position != -1)
{
event.description = event.description.replace("(DD)", "");
event.audioProps |= AUD_DOLBY;
event.audioProps |= AUD_STEREO;
}
// Remove SAP from Dish descriptions
position = event.description.indexOf("(SAP)");
if (position != -1)
{
event.description = event.description.replace("(SAP", "");
event.subtitleType |= SUB_HARDHEAR;
}
// Remove any trailing colon in title
position = event.title.indexOf(m_dishPPVTitleColon);
if (position != -1)
{
event.title = event.title.replace(m_dishPPVTitleColon, "");
}
// Remove New at the end of the description
position = event.description.indexOf(m_dishDescriptionNew);
if (position != -1)
{
event.previouslyshown = false;
event.description = event.description.replace(m_dishDescriptionNew, "");
}
// Remove Series Finale at the end of the desciption
position = event.description.indexOf(m_dishDescriptionFinale);
if (position != -1)
{
event.previouslyshown = false;
event.description = event.description.replace(m_dishDescriptionFinale, "");
}
// Remove Series Finale at the end of the desciption
position = event.description.indexOf(m_dishDescriptionFinale2);
if (position != -1)
{
event.previouslyshown = false;
event.description = event.description.replace(m_dishDescriptionFinale2, "");
}
// Remove Series Premiere at the end of the description
position = event.description.indexOf(m_dishDescriptionPremiere);
if (position != -1)
{
event.previouslyshown = false;
event.description = event.description.replace(m_dishDescriptionPremiere, "");
}
// Remove Series Premiere at the end of the description
position = event.description.indexOf(m_dishDescriptionPremiere2);
if (position != -1)
{
event.previouslyshown = false;
event.description = event.description.replace(m_dishDescriptionPremiere2, "");
}
// Remove Dish's PPV code at the end of the description
QRegExp ppvcode = m_dishPPVCode;
ppvcode.setCaseSensitivity(Qt::CaseInsensitive);
position = event.description.indexOf(ppvcode);
if (position != -1)
{
event.description = event.description.replace(ppvcode, "");
}
// Remove trailing garbage
position = event.description.indexOf(m_dishPPVSpacePerenEnd);
if (position != -1)
{
event.description = event.description.replace(m_dishPPVSpacePerenEnd, "");
}
// Check for subtitle "All Day (... Eastern)" in the subtitle
position = event.subtitle.indexOf(m_bellPPVSubtitleAllDay);
if (position != -1)
{
event.subtitle = event.subtitle.replace(m_bellPPVSubtitleAllDay, "");
}
// Check for description "(... Eastern)" in the description
position = event.description.indexOf(m_bellPPVDescriptionAllDay);
if (position != -1)
{
event.description = event.description.replace(m_bellPPVDescriptionAllDay, "");
}
// Check for description "(... ET)" in the description
position = event.description.indexOf(m_bellPPVDescriptionAllDay2);
if (position != -1)
{
event.description = event.description.replace(m_bellPPVDescriptionAllDay2, "");
}
// Check for description "(nnnnn)" in the description
position = event.description.indexOf(m_bellPPVDescriptionEventId);
if (position != -1)
{
event.description = event.description.replace(m_bellPPVDescriptionEventId, "");
}
}
/** \fn EITFixUp::SetUKSubtitle(DBEventEIT&) const
* \brief Use this in the United Kingdom to standardize DVB-T guide.
*/
void EITFixUp::SetUKSubtitle(DBEventEIT &event) const
{
QStringList strListColon = event.description.split(":");
QStringList strListEnd;
bool fColon = false, fQuotedSubtitle = false;
int nPosition1;
QString strEnd;
if (strListColon.count()>1)
{
bool fDoubleDot = false;
bool fSingleDot = true;
int nLength = strListColon[0].length();
nPosition1 = event.description.indexOf("..");
if ((nPosition1 < nLength) && (nPosition1 >= 0))
fDoubleDot = true;
nPosition1 = event.description.indexOf(".");
if (nPosition1==-1)
fSingleDot = false;
if (nPosition1 > nLength)
fSingleDot = false;
else
{
QString strTmp = event.description.mid(nPosition1+1,
nLength-nPosition1);
QStringList tmp = strTmp.split(" ");
if (((uint) tmp.size()) < kMaxDotToColon)
fSingleDot = false;
}
if (fDoubleDot)
{
strListEnd = strListColon;
fColon = true;
}
else if (!fSingleDot)
{
QStringList strListTmp;
uint nTitle=0;
int nTitleMax=-1;
int i;
for (i =0; (i<(int)strListColon.count()) && (nTitleMax==-1);i++)
{
const QStringList tmp = strListColon[i].split(" ");
nTitle += tmp.size();
if (nTitle < kMaxToTitle)
strListTmp.push_back(strListColon[i]);
else
nTitleMax=i;
}
QString strPartial;
for (i=0;i<(nTitleMax-1);i++)
strPartial+=strListTmp[i]+":";
if (nTitleMax>0)
{
strPartial+=strListTmp[nTitleMax-1];
strListEnd.push_back(strPartial);
}
for (i=nTitleMax+1;i<(int)strListColon.count();i++)
strListEnd.push_back(strListColon[i]);
fColon = true;
}
}
QRegExp tmpQuotedSubtitle = m_ukQuotedSubtitle;
if (tmpQuotedSubtitle.indexIn(event.description) != -1)
{
event.subtitle = tmpQuotedSubtitle.cap(1);
event.description.remove(m_ukQuotedSubtitle);
fQuotedSubtitle = true;
}
QStringList strListPeriod;
QStringList strListQuestion;
QStringList strListExcl;
if (!(fColon || fQuotedSubtitle))
{
strListPeriod = event.description.split(".");
if (strListPeriod.count() >1)
{
nPosition1 = event.description.indexOf(".");
int nPosition2 = event.description.indexOf("..");
if ((nPosition1 < nPosition2) || (nPosition2==-1))
strListEnd = strListPeriod;
}
strListQuestion = event.description.split("?");
strListExcl = event.description.split("!");
if ((strListQuestion.size() > 1) &&
((uint)strListQuestion.size() <= kMaxQuestionExclamation))
{
strListEnd = strListQuestion;
strEnd = "?";
}
else if ((strListExcl.size() > 1) &&
((uint)strListExcl.size() <= kMaxQuestionExclamation))
{
strListEnd = strListExcl;
strEnd = "!";
}
else
strEnd = QString::null;
}
if (!strListEnd.empty())
{
QStringList strListSpace = strListEnd[0].split(
" ", QString::SkipEmptyParts);
if (fColon && ((uint)strListSpace.size() > kMaxToTitle))
return;
if ((uint)strListSpace.size() > kDotToTitle)
return;
if (strListSpace.filter(m_ukExclusionFromSubtitle).empty())
{
event.subtitle = strListEnd[0]+strEnd;
event.subtitle.remove(m_ukSpaceColonStart);
event.description=
event.description.mid(strListEnd[0].length()+1);
event.description.remove(m_ukSpaceColonStart);
}
}
}
/** \fn EITFixUp::FixUK(DBEventEIT&) const
* \brief Use this in the United Kingdom to standardize DVB-T guide.
*/
void EITFixUp::FixUK(DBEventEIT &event) const
{
int position1;
int position2;
QString strFull;
bool isMovie = event.category.startsWith("Movie",Qt::CaseInsensitive);
// BBC three case (could add another record here ?)
event.description = event.description.remove(m_ukThen);
event.description = event.description.remove(m_ukNew);
// Removal of Class TV, CBBC and CBeebies etc..
event.title = event.title.remove(m_ukTitleRemove);
event.description = event.description.remove(m_ukDescriptionRemove);
// Removal of BBC FOUR and BBC THREE
event.description = event.description.remove(m_ukBBC34);
// BBC 7 [Rpt of ...] case.
event.description = event.description.remove(m_ukBBC7rpt);
// "All New To 4Music!
event.description = event.description.remove(m_ukAllNew);
// Remove [AD,S] etc.
QRegExp tmpCC = m_ukCC;
if ((position1 = tmpCC.indexIn(event.description)) != -1)
{
QStringList tmpCCitems = tmpCC.cap(0).remove("[").remove("]").split(",");
if (tmpCCitems.contains("AD"))
event.audioProps |= AUD_VISUALIMPAIR;
if (tmpCCitems.contains("S"))
event.subtitleType |= SUB_NORMAL;
if (tmpCCitems.contains("SL"))
event.subtitleType |= SUB_SIGNED;
if (tmpCCitems.contains("W"))
event.videoProps |= VID_WIDESCREEN;
event.description = event.description.remove(m_ukCC);
}
event.title = event.title.trimmed();
event.description = event.description.trimmed();
// Work out the episode numbers (if any)
bool series = false;
QRegExp tmpExp1 = m_ukSeries;
if ((position1 = tmpExp1.indexIn(event.title)) != -1)
{
if ((tmpExp1.cap(1).toUInt() <= tmpExp1.cap(2).toUInt())
&& tmpExp1.cap(2).toUInt()<=50)
{
event.partnumber = tmpExp1.cap(1).toUInt();
event.parttotal = tmpExp1.cap(2).toUInt();
// Remove from the title
event.title = event.title.left(position1) +
event.title.mid(position1 + tmpExp1.cap(0).length());
series = true;
}
}
else if ((position1 = tmpExp1.indexIn(event.description)) != -1)
{
if ((tmpExp1.cap(1).toUInt() <= tmpExp1.cap(2).toUInt())
&& tmpExp1.cap(2).toUInt()<=50)
{
event.partnumber = tmpExp1.cap(1).toUInt();
event.parttotal = tmpExp1.cap(2).toUInt();
#if 0 // Remove from the description
event.description = event.description.left(position1) +
event.description.mid(position1+tmpExp1.cap(0).length());
#endif
series = true;
}
}
if (series)
event.categoryType = kCategorySeries;
QRegExp tmpStarring = m_ukStarring;
if (tmpStarring.indexIn(event.description) != -1)
{
// if we match this we've captured 2 actors and an (optional) airdate
event.AddPerson(DBPerson::kActor, tmpStarring.cap(1));
event.AddPerson(DBPerson::kActor, tmpStarring.cap(2));
if (tmpStarring.cap(3).length() > 0)
{
bool ok;
uint y = tmpStarring.cap(3).toUInt(&ok);
if (ok)
{
event.airdate = y;
event.originalairdate = QDate(y, 1, 1);
}
}
}
QRegExp tmp24ep = m_uk24ep;
if (!event.title.startsWith("CSI:") && !event.title.startsWith("CD:"))
{
if (((position1=event.title.indexOf(m_ukDoubleDotEnd)) != -1) &&
((position2=event.description.indexOf(m_ukDoubleDotStart)) != -1))
{
QString strPart=event.title.remove(m_ukDoubleDotEnd)+" ";
strFull = strPart + event.description.remove(m_ukDoubleDotStart);
if (isMovie &&
((position1 = strFull.indexOf(m_ukCEPQ,strPart.length())) != -1))
{
if (strFull[position1] == '!' || strFull[position1] == '?')
position1++;
event.title = strFull.left(position1);
event.description = strFull.mid(position1 + 1);
event.description.remove(m_ukSpaceStart);
}
else if ((position1 = strFull.indexOf(m_ukCEPQ)) != -1)
{
if (strFull[position1] == '!' || strFull[position1] == '?')
position1++;
event.title = strFull.left(position1);
event.description = strFull.mid(position1 + 1);
event.description.remove(m_ukSpaceStart);
SetUKSubtitle(event);
}
if ((position1 = strFull.indexOf(m_ukYear)) != -1)
{
// Looks like they are using the airdate as a delimiter
if ((uint)position1 < SUBTITLE_MAX_LEN)
{
event.description = event.title.mid(position1);
event.title = event.title.left(position1);
}
}
}
else if ((position1 = tmp24ep.indexIn(event.description)) != -1)
{
// Special case for episodes of 24.
// -2 from the length cause we don't want ": " on the end
event.subtitle = event.description.mid(position1,
tmp24ep.cap(0).length() - 2);
event.description = event.description.remove(tmp24ep.cap(0));
}
else if ((position1 = event.description.indexOf(m_ukTime)) == -1)
{
if (!isMovie && (event.title.indexOf(m_ukYearColon) < 0))
{
if (((position1 = event.title.indexOf(":")) != -1) &&
(event.description.indexOf(":") < 0 ))
{
if (event.title.mid(position1+1).indexOf(m_ukCompleteDots)==0)
{
SetUKSubtitle(event);
QString strTmp = event.title.mid(position1+1);
event.title.resize(position1);
event.subtitle = strTmp+event.subtitle;
}
else if ((uint)position1 < SUBTITLE_MAX_LEN)
{
event.subtitle = event.title.mid(position1 + 1);
event.title = event.title.left(position1);
}
}
else
SetUKSubtitle(event);
}
}
}
if (!isMovie && event.subtitle.isEmpty())
{
if ((position1=event.description.indexOf(m_ukTime)) != -1)
{
position2 = event.description.indexOf(m_ukColonPeriod);
if ((position2>=0) && (position2 < (position1-2)))
SetUKSubtitle(event);
}
else if ((position1=event.title.indexOf("-")) != -1)
{
if ((uint)position1 < SUBTITLE_MAX_LEN)
{
event.subtitle = event.title.mid(position1 + 1);
event.subtitle.remove(m_ukSpaceColonStart);
event.title = event.title.left(position1);
}
}
else
SetUKSubtitle(event);
}
// Work out the year (if any)
QRegExp tmpUKYear = m_ukYear;
if ((position1 = tmpUKYear.indexIn(event.description)) != -1)
{
QString stmp = event.description;
int itmp = position1 + tmpUKYear.cap(0).length();
event.description = stmp.left(position1) + stmp.mid(itmp);
bool ok;
uint y = tmpUKYear.cap(1).toUInt(&ok);
if (ok)
{
event.airdate = y;
event.originalairdate = QDate(y, 1, 1);
}
}
// Trim leading/trailing '.'
event.subtitle.remove(m_ukDotSpaceStart);
if (event.subtitle.lastIndexOf("..") != (((int)event.subtitle.length())-2))
event.subtitle.remove(m_ukDotEnd);
// Reverse the subtitle and empty description
if (event.description.isEmpty() && !event.subtitle.isEmpty())
{
event.description=event.subtitle;
event.subtitle=QString::null;
}
}
/** \fn EITFixUp::FixPBS(DBEventEIT&) const
* \brief Use this to standardize PBS ATSC guide in the USA.
*/
void EITFixUp::FixPBS(DBEventEIT &event) const
{
/* Used for PBS ATSC Subtitles are separated by a colon */
int position = event.description.indexOf(':');
if (position != -1)
{
const QString stmp = event.description;
event.subtitle = stmp.left(position);
event.description = stmp.right(stmp.length() - position - 2);
}
}
/**
* \brief Use this to standardize ComHem DVB-C service in Sweden.
*/
void EITFixUp::FixComHem(DBEventEIT &event, bool process_subtitle) const
{
// Reverse what EITFixUp::Fix() did
if (event.subtitle.isEmpty() && !event.description.isEmpty())
{
event.subtitle = event.description;
event.description = "";
}
// Remove subtitle, it contains the category and we already know that
event.subtitle = "";
bool isSeries = false;
// Try to find episode numbers
int pos;
QRegExp tmpSeries1 = m_comHemSeries1;
QRegExp tmpSeries2 = m_comHemSeries2;
if ((pos = tmpSeries2.indexIn(event.title)) != -1)
{
QStringList list = tmpSeries2.capturedTexts();
event.partnumber = list[2].toUInt();
event.title = event.title.replace(list[0],"");
}
else if ((pos = tmpSeries1.indexIn(event.description)) != -1)
{
QStringList list = tmpSeries1.capturedTexts();
if (!list[1].isEmpty())
{
event.partnumber = list[1].toUInt();
}
if (!list[2].isEmpty())
{
event.parttotal = list[2].toUInt();
}
// Remove the episode numbers, but only if it's not at the begining
// of the description (subtitle code might use it)
if(pos > 0)
event.description = event.description.replace(list[0],"");
isSeries = true;
}
// Add partnumber/parttotal to subtitle
// This will be overwritten if we find a better subtitle
if (event.partnumber > 0)
{
event.subtitle = QString("Del %1").arg(event.partnumber);
if (event.parttotal > 0)
{
event.subtitle += QString(" av %1").arg(event.parttotal);
}
}
// Move subtitle info from title to subtitle
QRegExp tmpTSub = m_comHemTSub;
if (tmpTSub.indexIn(event.title) != -1)
{
event.subtitle = tmpTSub.cap(1);
event.title = event.title.replace(tmpTSub.cap(0),"");
}
// No need to continue without a description.
if (event.description.length() <= 0)
return;
// Try to find country category, year and possibly other information
// from the begining of the description
QRegExp tmpCountry = m_comHemCountry;
pos = tmpCountry.indexIn(event.description);
if (pos != -1)
{
QStringList list = tmpCountry.capturedTexts();
QString replacement;
// Original title, usually english title
// note: list[1] contains extra () around the text that needs removing