Ticket #2745: 2745_non_fuzzy.diff

File 2745_non_fuzzy.diff, 5.7 KB (added by Janne <janne-mythtv@…>, 13 years ago)
  • mythtv/libs/libmythtv/eitfixup.cpp

    diff --git a/mythtv/libs/libmythtv/eitfixup.cpp b/mythtv/libs/libmythtv/eitfixup.cpp
    index e8f8d88..7ca8a30 100644
    a b EITFixUp::EITFixUp() 
    4848      m_mcaActorsSeparator("(,\\s+)"),
    4949      m_mcaYear("(.*) \\((\\d{4})\\)\\s*$"),
    5050      m_mcaCC("(.*)\\. HI Subtitles$"),
    51       m_RTLSubtitle("([^\\.]+)\\.\\s+(.+)"),
     51      m_RTLrepeat("(\\(|\\s)?Wiederholung.+vo[m|n].+((?:\\d{2}\\.\\d{2}\\.\\d{4})|(?:\\d{2}[:\\.]\\d{2}\\sUhr))\\)?"),
     52      m_RTLSubtitle1("^Folge\\s(\\d{1,4})\\s*:\\s+'(.*)'(?:\\.\\s*|$)"),
     53      m_RTLSubtitle2("^Folge\\s(\\d{1,4})\\s+(.{,5}[^\\.]{,120})[\\?!\\.]\\s*"),
     54      m_RTLSubtitle3("^(?:Folge\\s)?(\\d{1,4}(?:\\/[IVX]+)?)\\s+(.{,5}[^\\.]{,120})[\\?!\\.]\\s*"),
     55      m_RTLSubtitle4("^Thema.{0,5}:\\s([^\\.]+)\\.\\s*"),
     56      m_RTLSubtitle5("^'(.+)'\\.\\s*"),
     57      m_RTLEpisodeNo1("^(Folge\\s\\d{1,4})\\.*\\s*"),
     58      m_RTLEpisodeNo2("^(\\d{1,2}\\/[IVX]+)\\.*\\s*"),
    5259      m_fiRerun("Uusinta.?"),
    5360      m_Stereo("(Stereo)")
    5461{
    void EITFixUp::FixMCA(DBEvent &event) const 
    742749 */
    743750void EITFixUp::FixRTL(DBEvent &event) const
    744751{
    745     const uint SUBTITLE_PCT = 35; //% of description to allow subtitle up to
    746     const uint SUBTITLE_MAX_LEN = 128; // max length of subtitle field in db.
    747     int        position;
    748     QRegExp    tmpExp1;
     752    int        pos;
    749753
    750     // No need to continue without a description.
    751     if (event.description.length() <= 0)
    752     {
     754    // No need to continue without a description and with an subtitle.
     755    if (event.description.length() <= 0 || event.subtitle.length() > 0)
    753756        return;
    754     }
    755     // Try to find subtitle in description
    756     tmpExp1 = m_RTLSubtitle;
    757     if ((position = tmpExp1.search(event.description)) != -1)
    758     {
    759         if ((tmpExp1.cap(1).length() < SUBTITLE_MAX_LEN) &&
    760             ((tmpExp1.cap(1).length()*100)/event.description.length() <
    761              SUBTITLE_PCT))
    762         {
    763             event.subtitle    = tmpExp1.cap(1);
    764             event.description = tmpExp1.cap(2);
    765         }
     757
     758    // Repeat
     759    QRegExp tmpExpRepeat = m_RTLrepeat;
     760    if ((pos = tmpExpRepeat.search(event.description)) != -1)
     761    {
     762        // remove '.' if it matches at the beginning of the description
     763        int length = tmpExpRepeat.cap(0).length() + (pos ? 0 : 1);
     764        event.description =
     765            event.description.remove(pos, length).stripWhiteSpace();
     766        event.originalairdate = event.starttime.addDays(-1).date();
     767    }
     768   
     769    QRegExp tmpExpSubtitle1 = m_RTLSubtitle1;
     770    tmpExpSubtitle1.setMinimal(true);
     771    QRegExp tmpExpSubtitle2 = m_RTLSubtitle2;
     772    QRegExp tmpExpSubtitle3 = m_RTLSubtitle3;
     773    QRegExp tmpExpSubtitle4 = m_RTLSubtitle4;
     774    QRegExp tmpExpSubtitle5 = m_RTLSubtitle5;
     775    tmpExpSubtitle5.setMinimal(true);
     776    QRegExp tmpExpEpisodeNo1 = m_RTLEpisodeNo1;
     777    QRegExp tmpExpEpisodeNo2 = m_RTLEpisodeNo2;
     778
     779    // subtitle with episode number: "Folge *: 'subtitle'. description
     780    if (tmpExpSubtitle1.search(event.description) != -1)
     781    {
     782        event.syndicatedepisodenumber = tmpExpSubtitle1.cap(1);
     783        event.subtitle    = tmpExpSubtitle1.cap(2);
     784        event.description =
     785            event.description.remove(0, tmpExpSubtitle1.matchedLength());
     786    }
     787    // episode number subtitle
     788    else if (tmpExpSubtitle2.search(event.description) != -1)
     789    {
     790        event.syndicatedepisodenumber = tmpExpSubtitle2.cap(1);
     791        event.subtitle    = tmpExpSubtitle2.cap(2);
     792        event.description =
     793            event.description.remove(0, tmpExpSubtitle2.matchedLength());
     794    }
     795    // episode number subtitle
     796    else if (tmpExpSubtitle3.search(event.description) != -1)
     797    {
     798        event.syndicatedepisodenumber = tmpExpSubtitle3.cap(1);
     799        event.subtitle    = tmpExpSubtitle3.cap(2);
     800        event.description =
     801            event.description.remove(0, tmpExpSubtitle3.matchedLength());
     802    }
     803    // "Thema..."
     804    else if (tmpExpSubtitle4.search(event.description) != -1)
     805    {
     806        event.subtitle    = tmpExpSubtitle4.cap(1);
     807        event.description =
     808            event.description.remove(0, tmpExpSubtitle4.matchedLength());
     809    }
     810    // "'...'"
     811    else if (tmpExpSubtitle5.search(event.description) != -1)
     812    {
     813        event.subtitle    = tmpExpSubtitle5.cap(1);
     814        event.description =
     815            event.description.remove(0, tmpExpSubtitle5.matchedLength());
     816    }
     817    // episode number
     818    else if (tmpExpEpisodeNo1.search(event.description) != -1)
     819    {
     820        event.syndicatedepisodenumber = tmpExpEpisodeNo1.cap(2);
     821        event.subtitle    = tmpExpEpisodeNo1.cap(1);
     822        event.description =
     823            event.description.remove(0, tmpExpEpisodeNo1.matchedLength());
     824    }
     825    // episode number
     826    else if (tmpExpEpisodeNo2.search(event.description) != -1)
     827    {
     828        event.syndicatedepisodenumber = tmpExpEpisodeNo2.cap(2);
     829        event.subtitle    = tmpExpEpisodeNo2.cap(1);
     830        event.description =
     831            event.description.remove(0, tmpExpEpisodeNo2.matchedLength());
    766832    }
    767833}
    768834
  • mythtv/libs/libmythtv/eitfixup.h

    diff --git a/mythtv/libs/libmythtv/eitfixup.h b/mythtv/libs/libmythtv/eitfixup.h
    index 58c0872..e04150a 100644
    a b class EITFixUp 
    9696    const QRegExp m_mcaActorsSeparator;
    9797    const QRegExp m_mcaYear;
    9898    const QRegExp m_mcaCC;
    99     const QRegExp m_RTLSubtitle;
     99    const QRegExp m_RTLrepeat;
     100    const QRegExp m_RTLSubtitle1;
     101    const QRegExp m_RTLSubtitle2;
     102    const QRegExp m_RTLSubtitle3;
     103    const QRegExp m_RTLSubtitle4;
     104    const QRegExp m_RTLSubtitle5;
     105    const QRegExp m_RTLEpisodeNo1;
     106    const QRegExp m_RTLEpisodeNo2;
    100107    const QRegExp m_fiRerun;
    101108    const QRegExp m_Stereo;
    102109};