Ticket #4327: eitfixup12.patch
File eitfixup12.patch, 17.2 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 = strList3; 322 strEnd = "?"; 323 } 324 if (strList1.count()>1) 325 strList = strList1; 326 } 327 328 if (strList.count()) 329 { 330 strList1 = QStringList::split(" ",strList[0]); 331 if (fColon || (strList1.count() < kDotToTitle)) 332 { 333 if ((strList1.grep("Drama",false).count()==0) && 334 (strList1.grep("sitcom",false).count()==0) && 335 (strList1.grep("Series",false).count()==0) && 336 (strList1.grep(m_ukStarring1).count()==0)) 330 337 { 331 if ((uint)position1 < SUBTITLE_MAX_LEN) 332 { 333 event.subtitle = event.description.left(position1); 334 event.description = event.description.mid(position1+1); 335 } 338 event.subtitle = strList[0]+strEnd; 339 event.description= 340 event.description.mid(strList[0].length()+1); 336 341 } 337 342 } 338 343 } … … 347 352 int position2; 348 353 QString strFull; 349 354 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 355 bool isMovie = event.category.startsWith("Movie",false); 357 356 // BBC three case (could add another record here ?) 358 357 event.description = event.description.remove(m_ukThen); 359 358 event.description = event.description.remove(m_ukNew); … … 372 371 // BBC 7 [Rpt of ...] case. 373 372 event.description = event.description.remove(m_ukBBC7rpt); 374 373 374 // Remove [AD,S] etc. 375 event.description = event.description.remove(m_ukCC); 376 375 377 event.title = event.title.stripWhiteSpace(); 376 378 event.description = event.description.stripWhiteSpace(); 377 379 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 380 // Work out the episode numbers (if any) 487 381 bool series = false; 488 382 QRegExp tmpExp1 = m_ukSeries1; … … 501 395 series = true; 502 396 } 503 397 } 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 398 else if ((position1 = tmpExp1.search(event.description)) != -1) 518 399 { 519 400 if ((tmpExp1.cap(1).toUInt() <= tmpExp1.cap(2).toUInt()) … … 548 429 if (series) 549 430 event.category_type = kCategorySeries; 550 431 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) 432 QRegExp tmpStarring2 = m_ukStarring2; 433 if (tmpStarring2.search(event.description) != -1) 556 434 { 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)435 // if we match this we've captured 2 actors and an (optional) airdate 436 event.AddPerson(DBPerson::kActor, tmpStarring2.cap(1)); 437 event.AddPerson(DBPerson::kActor, tmpStarring2.cap(2)); 438 if (tmpStarring2.cap(3).length() > 0) 561 439 { 562 if (*it == "S") 563 event.subtitleType |= SUB_NORMAL; 440 event.airdate = tmpStarring2.cap(3); 441 bool ok; 442 uint y = tmpStarring2.cap(3).toUInt(&ok); 443 if (ok) 444 event.originalairdate = QDate(y, 1, 1); 564 445 } 565 446 } 566 else if ((position1 = tmpUKCC.search(event.subtitle)) != -1) 447 448 QRegExp tmp24ep = m_uk24ep; 449 if (!event.title.startsWith("CSI:") && !event.title.startsWith("CD:")) 567 450 { 568 captures = tmpUKCC.capturedTexts();569 for (it = captures.begin(); it != captures.end(); ++it)451 if (((position1=event.title.find(m_ukDoubleDotEnd)) != -1) && 452 ((position2=event.description.find(m_ukDoubleDotStart)) != -1)) 570 453 { 571 if (*it == "S") 572 event.subtitleType |= SUB_NORMAL; 454 QString strPart=event.title.remove(m_ukDoubleDotEnd)+" "; 455 strFull = strPart + event.description.remove(m_ukDoubleDotStart); 456 if (isMovie && 457 ((position1 = strFull.find(m_ukCEPQ,strPart.length())) != -1)) 458 { 459 if (strFull[position1] == '!' || strFull[position1] == '?' || 460 strFull[position1] == '.') 461 position1++; 462 event.title = strFull.left(position1); 463 event.description = strFull.mid(position1 + 1); 464 } 465 else if ((position1 = strFull.find(m_ukCEPQ)) != -1) 466 { 467 if (strFull[position1] == '!' || strFull[position1] == '?' || 468 strFull[position1] == '.') 469 position1++; 470 event.title = strFull.left(position1); 471 event.description = strFull.mid(position1 + 1); 472 SetUKSubtitle(event); 473 } 474 if ((position1 = strFull.find(m_ukYear)) != -1) 475 { 476 // Looks like they are using the airdate as a delimiter 477 if ((uint)position1 < SUBTITLE_MAX_LEN) 478 { 479 event.description = event.title.mid(position1); 480 event.title = event.title.left(position1); 481 } 482 } 573 483 } 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); 484 else if ((position1 = tmp24ep.search(event.description)) != -1) 485 { 486 // Special case for episodes of 24. 487 // -2 from the length cause we don't want ": " on the end 488 event.subtitle = event.description.mid(position1, 489 tmp24ep.cap(0).length() - 2); 490 event.description = event.description.remove(tmp24ep.cap(0)); 491 } 492 else if ((position1 = event.description.find(m_ukTime)) == -1) 493 { 494 if (!isMovie && (event.title.find(m_ukYearColon) < 0)) 495 { 496 if (((position1 = event.title.find(":")) != -1) && 497 (event.description.find(":") < 0 )) 498 { 499 if ((uint)position1 < SUBTITLE_MAX_LEN) 500 { 501 event.subtitle = event.title.mid(position1 + 1); 502 event.title = event.title.left(position1); 503 } 504 } 505 else 506 SetUKSubtitle(event); 507 } 508 } 579 509 } 580 510 511 if (!isMovie && (event.description.find(m_ukTime) == -1) && 512 (event.subtitle.isEmpty())) 513 SetUKSubtitle(event); 514 581 515 // Work out the year (if any) 582 516 QRegExp tmpUKYear = m_ukYear; 583 517 if ((position1 = tmpUKYear.search(event.description)) != -1) … … 593 527 } 594 528 595 529 // Trim trailing '.' 596 event.title.remove(m_ukPEnd); 597 event.subtitle.remove(m_ukPEnd); 530 event.title.remove(m_ukDotSpaceEnd); 598 531 event.subtitle.remove(m_ukDotSpaceStart); 532 event.subtitle.remove(m_ukDotSpaceEnd); 533 event.description.remove(m_ukDotSpaceStart); 599 534 } 600 535 601 536 /** \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;