41 | | m_comHemTSub("\\s+-\\s+([^\\-]+)") |
| 41 | m_comHemTSub("\\s+-\\s+([^\\-]+)"), |
| 42 | m_mcaIncompleteTitle("(.*)\\.\\.\\.$"), |
| 43 | m_mcaSubtitle("^'([^\\.]+)'\\.\\s+(.+)"), |
| 44 | m_mcaSeries("(^\\d+)\\/(\\d+) - (.*)$"), |
| 45 | m_mcaCredits("(.*) \\((\\d{4})\\)\\s*([^\\.]+)\\.?\\s*$"), |
| 46 | m_mcaActors("(.*\\.)\\s+([^\\.]+ [A-Z][^\\.]+)\\.\\s*"), |
| 47 | m_mcaActorsSeparator("(,\\s+)"), |
| 48 | m_mcaYear("(.*) \\((\\d{4})\\)\\s*$"), |
| 49 | m_mcaCC("(.*)\\. HI Subtitles$") |
| 643 | |
| 644 | /** \fn EITFixUp::FixMCA(DBEvent&) const |
| 645 | * \brief Use this to standardise the MultiChoice Africa DVB-S guide. |
| 646 | */ |
| 647 | void EITFixUp::FixMCA(DBEvent &event) const |
| 648 | { |
| 649 | const uint SUBTITLE_PCT = 35; //% of description to allow subtitle up to |
| 650 | const uint SUBTITLE_MAX_LEN = 128; // max length of subtitle field in db. |
| 651 | int position; |
| 652 | QRegExp tmpExp1; |
| 653 | |
| 654 | // Remove subtitle, it contains category information too specific to use |
| 655 | event.subtitle = QString::null; |
| 656 | |
| 657 | // No need to continue without a description. |
| 658 | if (event.description.length() <= 0) |
| 659 | return; |
| 660 | |
| 661 | // Try to find subtitle in description |
| 662 | tmpExp1 = m_mcaSubtitle; |
| 663 | if ((position = tmpExp1.search(event.description)) != -1) |
| 664 | { |
| 665 | if ((tmpExp1.cap(1).length() < SUBTITLE_MAX_LEN) && |
| 666 | ((tmpExp1.cap(1).length()*100)/event.description.length() < |
| 667 | SUBTITLE_PCT)) |
| 668 | { |
| 669 | event.subtitle = tmpExp1.cap(1); |
| 670 | event.description = tmpExp1.cap(2); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | // Replace incomplete titles if the full one is the subtitle |
| 675 | tmpExp1 = m_mcaIncompleteTitle; |
| 676 | if (tmpExp1.search(event.title) != -1) |
| 677 | { |
| 678 | if (event.subtitle.find(tmpExp1.cap(1)) == 0) |
| 679 | { |
| 680 | event.title = event.subtitle; |
| 681 | event.subtitle = QString::null; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | // Try to find episode numbers in subtitle |
| 686 | tmpExp1 = m_mcaSeries; |
| 687 | if ((position = tmpExp1.search(event.subtitle)) != -1) |
| 688 | { |
| 689 | uint season = tmpExp1.cap(1).toUInt(); |
| 690 | uint episode = tmpExp1.cap(2).toUInt(); |
| 691 | event.subtitle = tmpExp1.cap(3).stripWhiteSpace(); |
| 692 | event.syndicatedepisodenumber = |
| 693 | QString("E%1S%2").arg(episode).arg(season); |
| 694 | event.category_type = kCategorySeries; |
| 695 | } |
| 696 | |
| 697 | // Close captioned? |
| 698 | position = event.description.find(m_mcaCC); |
| 699 | if (position != -1) |
| 700 | { |
| 701 | event.flags |= DBEvent::kCaptioned; |
| 702 | event.description.replace(m_mcaCC, ""); |
| 703 | } |
| 704 | |
| 705 | |
| 706 | bool isMovie = false; |
| 707 | // Try to find year and director from the end of the description |
| 708 | tmpExp1 = m_mcaCredits; |
| 709 | position = tmpExp1.search(event.description); |
| 710 | if (position != -1) |
| 711 | { |
| 712 | isMovie = true; |
| 713 | event.airdate = tmpExp1.cap(2).stripWhiteSpace(); |
| 714 | event.AddPerson(DBPerson::kDirector, tmpExp1.cap(3).stripWhiteSpace()); |
| 715 | event.description = tmpExp1.cap(1).stripWhiteSpace(); |
| 716 | } |
| 717 | else |
| 718 | { |
| 719 | // Try to find year only from the end of the description |
| 720 | tmpExp1 = m_mcaYear; |
| 721 | position = tmpExp1.search(event.description); |
| 722 | if (position != -1) |
| 723 | { |
| 724 | isMovie = true; |
| 725 | event.airdate = tmpExp1.cap(2).stripWhiteSpace(); |
| 726 | event.description = tmpExp1.cap(1).stripWhiteSpace(); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | if (isMovie) |
| 731 | { |
| 732 | tmpExp1 = m_mcaActors; |
| 733 | position = tmpExp1.search(event.description); |
| 734 | if (position != -1) |
| 735 | { |
| 736 | QStringList actors; |
| 737 | actors = QStringList::split(m_mcaActorsSeparator,tmpExp1.cap(2)); |
| 738 | for(QStringList::size_type i = 0; i < actors.count(); ++i) |
| 739 | event.AddPerson(DBPerson::kActor, actors[i].stripWhiteSpace()); |
| 740 | event.description = tmpExp1.cap(1).stripWhiteSpace(); |
| 741 | } |
| 742 | event.category_type = kCategoryMovie; |
| 743 | } |
| 744 | } |