Ticket #2352: mca_2-2.diff

File mca_2-2.diff, 6.3 KB (added by Stuart Auchterlonie, 18 years ago)

Update to the 2nd patch

  • libs/libmythtv/eitfixup.cpp

     
    3838      m_comHemSeries1("\\s?(?:[dD]el|[eE]pisode)\\s([0-9]+)"
    3939                      "(?:\\s?(?:/|:|av)\\s?([0-9]+))?\\."),
    4040      m_comHemSeries2("\\s?-?\\s?([Dd]el\\s+([0-9]+))"),
    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$")
    4250{
    4351}
    4452
     
    7179    if (kFixAUStar & event.fixup)
    7280        FixAUStar(event);
    7381
     82    if (kFixMCA & event.fixup)
     83        FixMCA(event);
     84
    7485    if (event.fixup)
    7586    {
    7687        if (!event.title.isEmpty())
     
    629640        event.description    = stmp.right(stmp.length() - position - 2);
    630641    }
    631642}
     643
     644/** \fn EITFixUp::FixMCA(DBEvent&) const
     645 *  \brief Use this to standardise the MultiChoice Africa DVB-S guide.
     646 */
     647void 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}
  • libs/libmythtv/eithelper.cpp

     
    518518    fix[ 769LL << 32 | 8468 << 16] = EITFixUp::kEFixPro7Sat; // DVB-T Berlin
    519519    fix[3075LL << 32 | 8468 << 16] = EITFixUp::kEFixPro7Sat; // DVB-T Bremen
    520520    fix[                133 << 16] = EITFixUp::kEFixPro7Sat; // Premiere and pro7/Sat.1
     521
     522    fix[ 6144 << 16] = EITFixUp::kFixMCA;
    521523}
    522524
    523525static int calc_eit_utc_offset(void)
  • libs/libmythtv/eitfixup.h

     
    2727        kFixComHem     = 0x0010,
    2828        kFixSubtitle   = 0x0020,
    2929        kFixAUStar     = 0x0040,
     30        kFixMCA        = 0x0080,
    3031
    3132        // Early fixups
    3233        kEFixPro7Sat   = 0x0100,
     
    5152    void FixPBS(DBEvent &event) const;           // USA ATSC
    5253    void FixComHem(DBEvent &event, bool parse_subtitle) const; // Sweden DVB-C
    5354    void FixAUStar(DBEvent &event) const;        // Australia DVB-S
     55    void FixMCA(DBEvent &event) const;        // MultiChoice Africa DVB-S
    5456
    5557    const QRegExp m_bellYear;
    5658    const QRegExp m_bellActors;
     
    8082    const QRegExp m_comHemSeries1;
    8183    const QRegExp m_comHemSeries2;
    8284    const QRegExp m_comHemTSub;
     85    const QRegExp m_mcaIncompleteTitle;
     86    const QRegExp m_mcaSubtitle;
     87    const QRegExp m_mcaSeries;
     88    const QRegExp m_mcaCredits;
     89    const QRegExp m_mcaActors;
     90    const QRegExp m_mcaActorsSeparator;
     91    const QRegExp m_mcaYear;
     92    const QRegExp m_mcaCC;
    8393};
    8494
    8595#endif // EITFIXUP_H