Ticket #4327: eitfixup13.patch
File eitfixup13.patch, 17.3 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/eitfixup.cpp
17 17 m_bellPPVDescriptionAllDay("^\\(.*\\sEastern\\)"), 18 18 m_bellPPVDescriptionAllDay2("^\\([0-9].*am-[0-9].*am\\sET\\)"), 19 19 m_bellPPVDescriptionEventId("\\([0-9]{5}\\)"), 20 m_ukSubtitle("\\[.*S\\]"),21 20 m_ukThen("\\s*(Then|Followed by) 60 Seconds\\.", false), 22 m_ukNew(" \\s*(Brand New|New)\\s*(Series|Episode)\\s*[:\\.\\-]",false),21 m_ukNew("(New\\.|\\s*(Brand New|New)\\s*(Series|Episode)\\s*[:\\.\\-])",false), 23 22 m_ukT4("^[tT]4:"), 24 m_ukEQ("[:\\!\\?]"), 25 m_ukEPQ("[:\\!\\.\\?]"), 26 m_ukPStart("^\\.+"), 27 m_ukPEnd("\\.+$"), 23 m_ukCEPQ("[:\\!\\.\\?]"), 24 m_ukDotSpaceStart("^[\\. ]+"), 25 m_ukDotSpaceEnd("[\\. ]+$"), 28 26 m_ukSeries1("\\s*(\\d{1,2})/(\\d{1,2})"), 29 27 m_ukSeries2("\\((Part|Pt)\\s+(\\d{1,2})\\s+of\\s+(\\d{1,2})\\)", false), 30 28 m_ukSeries3("\\s*Episode\\s+(\\d{1,2})\\s+of\\s+(\\d{1,2})\\.", false), … … 32 30 "\\[(SL)(,AD){,1}(,(S)){,1}\\]"), 33 31 m_ukYear("[\\[\\(]([\\d]{4})[\\)\\]]"), 34 32 m_uk24ep("^\\d{1,2}:00[ap]m to \\d{1,2}:00[ap]m: "), 35 m_ukStarring("(?:Western\\s)?[Ss]tarring ([\\w\\s\\-']+)[Aa]nd\\s([\\w\\s\\-']+)[\\.|,](?:\\s)*(\\d{4})?(?:\\.\\s)?"), 33 m_ukStarring2("(?:Western\\s)?[Ss]tarring ([\\w\\s\\-']+)[Aa]nd\\s([\\w\\s\\-']+)[\\.|,](?:\\s)*(\\d{4})?(?:\\.\\s)?"), 34 m_ukStarring1("star(ring|s)",false), 36 35 m_ukBBC7rpt("\\[Rptd?[^]]+\\d{1,2}\\.\\d{1,2}[ap]m\\]\\."), 37 36 m_ukCBBC("^CBBC\\s*[\\.]"), 38 37 m_ukCBeebies("^CBeebies\\s*[\\.]"), 39 m_ukStarring1("star(ring|s)"),40 38 m_ukDoubleDotEnd("\\.\\.+$"), 41 39 m_ukDoubleDotStart("^\\.\\.+"), 42 m_ukDotSpaceStart("^\\. "),43 40 m_ukTime("\\d{1,2}[\\.:]\\d{1,2}\\s*(am|pm|)"), 44 41 m_ukBBC34("BBC [THREE|FOUR] on BBC [ONE|TWO]\\.",false), 45 42 m_ukBBCSwitch("BBC Switch\\."), 46 m_ukYearColon("^ \\d\\d\\d\\d:"),43 m_ukYearColon("^[\\d]{4}:"), 47 44 m_comHemCountry("^(\\(.+\\))?\\s?([^ ]+)\\s([^\\.0-9]+)" 48 45 "(?:\\sfrån\\s([0-9]{4}))(?:\\smed\\s([^\\.]+))?\\.?"), 49 46 m_comHemDirector("[Rr]egi"), … … 299 296 300 297 void EITFixUp::SetUKSubtitle(DBEvent &event) const 301 298 { 302 QStringList strList1; 303 int position1; 304 int position2; 299 QStringList strList1 = QStringList::split(".",event.description,TRUE); 300 QStringList strList2 = QStringList::split("?",event.description,TRUE); 301 QStringList strList3 = QStringList::split("!",event.description,TRUE); 302 QStringList strList4 = QStringList::split(":",event.description,TRUE); 303 QStringList strList; 305 304 306 if ((position1 = event.description.find(m_ukEQ)) != -1) 305 bool fColon = false; 306 QString strEnd; 307 if (strList4.count()>1) 307 308 { 308 position2 = event.description.find(":",position1+1); 309 if (position2 != -1) 309 fColon = true; 310 strList = strList4; 311 } 312 else 313 { 314 if (strList3.count()>1) 310 315 { 311 strList1 = QStringList::split(" ", 312 event.description.mid(position1+1, 313 position2-position1+1)); 314 if (strList1.count() < kDotToTitle) 315 { 316 event.subtitle = event.description.left(position2); 317 event.description = event.description.mid(position2 + 1); 318 } 319 else 320 { 321 event.subtitle = event.description.left(position1); 322 event.description = event.description.mid(position1 + 1); 323 } 316 strList = strList3; 317 strEnd = "!"; 324 318 } 325 else319 if (strList2.count()>1) 326 320 { 327 strList1 = QStringList::split(" ", 328 event.description.left(position1)); 329 if (strList1.count() < kDotToTitle) 321 strList = strList2; 322 strEnd = "?"; 323 } 324 if (strList1.count()>1) 325 { 326 strList = strList1; 327 strEnd = QString::null; 328 } 329 } 330 331 if (strList.count()) 332 { 333 strList1 = QStringList::split(" ",strList[0]); 334 if (fColon || (strList1.count() < kDotToTitle)) 335 { 336 if ((strList1.grep("Drama",false).count()==0) && 337 (strList1.grep("sitcom",false).count()==0) && 338 (strList1.grep("Series",false).count()==0) && 339 (strList1.grep(m_ukStarring1).count()==0)) 330 340 { 331 if ((uint)position1 < SUBTITLE_MAX_LEN) 332 { 333 event.subtitle = event.description.left(position1); 334 event.description = event.description.mid(position1+1); 335 } 341 event.subtitle = strList[0]+strEnd; 342 event.description= 343 event.description.mid(strList[0].length()+1); 336 344 } 337 345 } 338 346 } … … 347 355 int position2; 348 356 QString strFull; 349 357 350 position1 = event.description.find(m_ukSubtitle); 351 if (position1 != -1) 352 { 353 event.subtitleType |= SUB_NORMAL; 354 event.description.remove(m_ukSubtitle); 355 } 356 358 bool isMovie = event.category.startsWith("Movie",false); 357 359 // BBC three case (could add another record here ?) 358 360 event.description = event.description.remove(m_ukThen); 359 361 event.description = event.description.remove(m_ukNew); … … 372 374 // BBC 7 [Rpt of ...] case. 373 375 event.description = event.description.remove(m_ukBBC7rpt); 374 376 377 // Remove [AD,S] etc. 378 event.description = event.description.remove(m_ukCC); 379 375 380 event.title = event.title.stripWhiteSpace(); 376 381 event.description = event.description.stripWhiteSpace(); 377 382 378 QRegExp tmp24ep = m_uk24ep;379 if (!event.title.startsWith("CSI:") && !event.title.startsWith("CD:"))380 {381 if (((position1=event.title.find(m_ukDoubleDotEnd)) != -1) &&382 ((position2=event.description.find(m_ukDoubleDotStart)) != -1))383 {384 strFull = event.title.remove(m_ukDoubleDotEnd)+" "+385 event.description.remove(m_ukDoubleDotStart);386 if ((position1 = strFull.find(m_ukEPQ)) != -1)387 {388 if (strFull[position1] == '!' || strFull[position1] == '?' ||389 strFull[position1] == '.')390 position1++;391 event.title = strFull.left(position1);392 event.description = strFull.mid(position1 + 1);393 SetUKSubtitle(event);394 }395 if ((position1 = strFull.find(m_ukYear)) != -1)396 {397 // Looks like they are using the airdate as a delimiter398 if ((uint)position1 < SUBTITLE_MAX_LEN)399 {400 event.description = event.title.mid(position1);401 event.title = event.title.left(position1);402 }403 }404 }405 else if ((position1 = tmp24ep.search(event.description)) != -1)406 {407 // Special case for episodes of 24.408 // -2 from the length cause we don't want ": " on the end409 event.subtitle = event.description.mid(position1,410 tmp24ep.cap(0).length() - 2);411 event.description = event.description.remove(tmp24ep.cap(0));412 }413 else if ((position1 = event.description.find(m_ukTime)) == -1)414 {415 if (event.title.find(m_ukYearColon) < 0)416 {417 if (((position1 = event.title.find(":")) != -1) &&418 (event.description.find(":") < 0 ))419 {420 if ((uint)position1 < SUBTITLE_MAX_LEN)421 {422 event.subtitle = event.title.mid(position1 + 1);423 event.title = event.title.left(position1);424 }425 }426 else427 SetUKSubtitle(event);428 }429 }430 }431 432 if ((event.description.find(m_ukTime) == -1) && (event.subtitle.isEmpty()))433 {434 QStringList strList1 = QStringList::split(".",event.description,TRUE);435 QStringList strList2 = QStringList::split("?",event.description,TRUE);436 if (strList1.count()>1 || strList2.count()>1)437 {438 QString strEnd;439 if (strList1[0].length() > strList2[0].length())440 {441 strList1=strList2;442 strEnd="?";443 }444 strList2 = QStringList::split(" ",strList1[0]);445 if (strList2.count() < kDotToTitle)446 {447 QStringList strList3 = strList2.grep("Drama",false);448 QStringList strList4 = strList2.grep("sitcom",false);449 QStringList strList5 = strList2.grep(m_ukStarring1);450 QStringList strList6 = strList2.grep("Series",false);451 if ((strList3.count()==0) && (strList4.count()==0) &&452 (strList5.count()==0) && (strList6.count()==0))453 {454 event.subtitle = strList1[0]+strEnd;455 event.description=456 event.description.mid(strList1[0].length()+1);457 }458 }459 }460 }461 462 QRegExp tmpStarring = m_ukStarring;463 if (tmpStarring.search(event.subtitle) != -1)464 {465 // If the "Starring..." string got promoted to subtitle move it back.466 event.description.prepend(". ");467 event.description.prepend(tmpStarring.cap(0));468 event.subtitle.remove(tmpStarring.cap(0));469 }470 tmpStarring = m_ukStarring;471 if (tmpStarring.search(event.description) != -1)472 {473 // if we match this we've captured 2 actors and an (optional) airdate474 event.AddPerson(DBPerson::kActor, tmpStarring.cap(1));475 event.AddPerson(DBPerson::kActor, tmpStarring.cap(2));476 if (tmpStarring.cap(3).length() > 0)477 {478 event.airdate = tmpStarring.cap(3);479 bool ok;480 uint y = tmpStarring.cap(3).toUInt(&ok);481 if (ok)482 event.originalairdate = QDate(y, 1, 1);483 }484 }485 486 383 // Work out the episode numbers (if any) 487 384 bool series = false; 488 385 QRegExp tmpExp1 = m_ukSeries1; … … 501 398 series = true; 502 399 } 503 400 } 504 else if ((position1 = tmpExp1.search(event.subtitle)) != -1)505 {506 if ((tmpExp1.cap(1).toUInt() <= tmpExp1.cap(2).toUInt())507 && tmpExp1.cap(2).toUInt()<=50)508 {509 event.partnumber = tmpExp1.cap(1).toUInt();510 event.parttotal = tmpExp1.cap(2).toUInt();511 // Remove from the subtitle512 event.subtitle = event.subtitle.left(position1) +513 event.subtitle.mid(position1 + tmpExp1.cap(0).length());514 series = true;515 }516 }517 401 else if ((position1 = tmpExp1.search(event.description)) != -1) 518 402 { 519 403 if ((tmpExp1.cap(1).toUInt() <= tmpExp1.cap(2).toUInt()) … … 548 432 if (series) 549 433 event.category_type = kCategorySeries; 550 434 551 // Work out the closed captions and Audio descriptions (if any) 552 QStringList captures; 553 QStringList::const_iterator it; 554 QRegExp tmpUKCC = m_ukCC; 555 if ((position1 = tmpUKCC.search(event.description)) != -1) 435 QRegExp tmpStarring2 = m_ukStarring2; 436 if (tmpStarring2.search(event.description) != -1) 556 437 { 557 // Enumerate throught and see if we have subtitles, don't modify558 // the description as we might destroy other useful information559 captures = tmpUKCC.capturedTexts();560 for (it = captures.begin(); it != captures.end(); ++it)438 // if we match this we've captured 2 actors and an (optional) airdate 439 event.AddPerson(DBPerson::kActor, tmpStarring2.cap(1)); 440 event.AddPerson(DBPerson::kActor, tmpStarring2.cap(2)); 441 if (tmpStarring2.cap(3).length() > 0) 561 442 { 562 if (*it == "S") 563 event.subtitleType |= SUB_NORMAL; 443 event.airdate = tmpStarring2.cap(3); 444 bool ok; 445 uint y = tmpStarring2.cap(3).toUInt(&ok); 446 if (ok) 447 event.originalairdate = QDate(y, 1, 1); 564 448 } 565 449 } 566 else if ((position1 = tmpUKCC.search(event.subtitle)) != -1) 450 451 QRegExp tmp24ep = m_uk24ep; 452 if (!event.title.startsWith("CSI:") && !event.title.startsWith("CD:")) 567 453 { 568 captures = tmpUKCC.capturedTexts();569 for (it = captures.begin(); it != captures.end(); ++it)454 if (((position1=event.title.find(m_ukDoubleDotEnd)) != -1) && 455 ((position2=event.description.find(m_ukDoubleDotStart)) != -1)) 570 456 { 571 if (*it == "S") 572 event.subtitleType |= SUB_NORMAL; 457 QString strPart=event.title.remove(m_ukDoubleDotEnd)+" "; 458 strFull = strPart + event.description.remove(m_ukDoubleDotStart); 459 if (isMovie && 460 ((position1 = strFull.find(m_ukCEPQ,strPart.length())) != -1)) 461 { 462 if (strFull[position1] == '!' || strFull[position1] == '?' || 463 strFull[position1] == '.') 464 position1++; 465 event.title = strFull.left(position1); 466 event.description = strFull.mid(position1 + 1); 467 } 468 else if ((position1 = strFull.find(m_ukCEPQ)) != -1) 469 { 470 if (strFull[position1] == '!' || strFull[position1] == '?' || 471 strFull[position1] == '.') 472 position1++; 473 event.title = strFull.left(position1); 474 event.description = strFull.mid(position1 + 1); 475 SetUKSubtitle(event); 476 } 477 if ((position1 = strFull.find(m_ukYear)) != -1) 478 { 479 // Looks like they are using the airdate as a delimiter 480 if ((uint)position1 < SUBTITLE_MAX_LEN) 481 { 482 event.description = event.title.mid(position1); 483 event.title = event.title.left(position1); 484 } 485 } 573 486 } 574 575 // We remove [AD,S] from the subtitle. 576 QString stmp = event.subtitle; 577 int itmp = position1 + tmpUKCC.cap(0).length(); 578 event.subtitle = stmp.left(position1) + stmp.mid(itmp); 487 else if ((position1 = tmp24ep.search(event.description)) != -1) 488 { 489 // Special case for episodes of 24. 490 // -2 from the length cause we don't want ": " on the end 491 event.subtitle = event.description.mid(position1, 492 tmp24ep.cap(0).length() - 2); 493 event.description = event.description.remove(tmp24ep.cap(0)); 494 } 495 else if ((position1 = event.description.find(m_ukTime)) == -1) 496 { 497 if (!isMovie && (event.title.find(m_ukYearColon) < 0)) 498 { 499 if (((position1 = event.title.find(":")) != -1) && 500 (event.description.find(":") < 0 )) 501 { 502 if ((uint)position1 < SUBTITLE_MAX_LEN) 503 { 504 event.subtitle = event.title.mid(position1 + 1); 505 event.title = event.title.left(position1); 506 } 507 } 508 else 509 SetUKSubtitle(event); 510 } 511 } 579 512 } 580 513 514 if (!isMovie && (event.description.find(m_ukTime) == -1) && 515 (event.subtitle.isEmpty())) 516 SetUKSubtitle(event); 517 581 518 // Work out the year (if any) 582 519 QRegExp tmpUKYear = m_ukYear; 583 520 if ((position1 = tmpUKYear.search(event.description)) != -1) … … 593 530 } 594 531 595 532 // Trim trailing '.' 596 event.title.remove(m_ukPEnd); 597 event.subtitle.remove(m_ukPEnd); 533 event.title.remove(m_ukDotSpaceEnd); 598 534 event.subtitle.remove(m_ukDotSpaceStart); 535 event.subtitle.remove(m_ukDotSpaceEnd); 536 event.description.remove(m_ukDotSpaceStart); 599 537 } 600 538 601 539 /** \fn EITFixUp::FixPBS(DBEvent&) const -
libs/libmythtv/eitfixup.h
79 79 const QRegExp m_bellPPVDescriptionAllDay; 80 80 const QRegExp m_bellPPVDescriptionAllDay2; 81 81 const QRegExp m_bellPPVDescriptionEventId; 82 const QRegExp m_ukSubtitle;83 82 const QRegExp m_ukThen; 84 83 const QRegExp m_ukNew; 85 84 const QRegExp m_ukT4; 86 const QRegExp m_ukEQ; 87 const QRegExp m_ukEPQ; 88 const QRegExp m_ukPStart; 89 const QRegExp m_ukPEnd; 85 const QRegExp m_ukCEPQ; 86 const QRegExp m_ukDotSpaceStart; 87 const QRegExp m_ukDotSpaceEnd; 90 88 const QRegExp m_ukSeries1; 91 89 const QRegExp m_ukSeries2; 92 90 const QRegExp m_ukSeries3; 93 91 const QRegExp m_ukCC; 94 92 const QRegExp m_ukYear; 95 93 const QRegExp m_uk24ep; 96 const QRegExp m_ukStarring; 94 const QRegExp m_ukStarring2; 95 const QRegExp m_ukStarring1; 97 96 const QRegExp m_ukBBC7rpt; 98 97 const QRegExp m_ukCBBC; 99 98 const QRegExp m_ukCBeebies; 100 const QRegExp m_ukStarring1;101 99 const QRegExp m_ukDoubleDotEnd; 102 100 const QRegExp m_ukDoubleDotStart; 103 const QRegExp m_ukDotSpaceStart;104 101 const QRegExp m_ukTime; 105 102 const QRegExp m_ukBBC34; 106 103 const QRegExp m_ukBBCSwitch;