Ticket #420: uk.eit.2.patch

File uk.eit.2.patch, 6.5 KB (added by John Pullan <john.pullan@…>, 19 years ago)
  • libs/libmythtv/siparser.cpp

     
    125125
    126126    pmap_lock.lock();
    127127
    128     /* Check Dependencys and update if necessary */
     128    /* Check Dependencies and update if necessary */
    129129    for (int x = 0 ; x < NumHandlers ; x++)
    130130    {
    131131        if (Table[x]->Complete())
     
    24292429#ifdef EIT_DEBUG_SID
    24302430        VERBOSE(VB_SIPARSER,
    24312431                QString("[%1][%2]: %3\t%4 - %5")
    2432                 .arg(source_id).arg(event_id)
     2432                .arg(atsc_src_id).arg(event_id)
    24332433                .arg(e.Event_Name.ascii(), 20)
    24342434                .arg(e.StartTime.toString("MM/dd hh:mm"))
    24352435                .arg(e.EndTime.toString("hh:mm")));
     
    29282928 */
    29292929void SIParser::EITFixUpStyle2(Event &event)
    29302930{
     2931    const uint16_t SUBTITLE_PCT = 50; //% of description to allow subtitle up to
    29312932    int16_t position = event.Description.find("New Series");
    29322933    if (position != -1)
    29332934    {
    29342935        //Do something here
    29352936    }
    29362937    //BBC three case (could add another record here ?)
    2937     event.Description = event.Description.replace(" Then 60 Seconds.","");
    2938     event.Description =
    2939         event.Description.replace(" Followed by 60 Seconds.","");
    2940     event.Description = event.Description.replace("Brand New Series - ","");
    2941     event.Description = event.Description.replace("Brand New Series","");
    2942     event.Description = event.Description.replace("New Series","");
     2938    QRegExp rx("\\s*(Then 60 Seconds| Followed by 60 Seconds)\\.");
     2939    rx.setCaseSensitive(FALSE);
     2940    event.Description = event.Description.replace(rx,"");
    29432941
     2942    rx.setPattern("\\s*(Brand New Series - |Brand New Series|New Series)\\.?:?");
     2943    event.Description = event.Description.replace(rx,"");
    29442944
     2945    QRegExp terminatesWith("[\\!\\?]");
    29452946    //This is trying to catch the case where the subtitle is in the main title
    29462947    //but avoid cases where it isn't a subtitle e.g cd:uk
    29472948    if (((position = event.Event_Name.find(":")) != -1) &&
     
    29532954    }
    29542955    else if ((position = event.Description.find(":")) != -1)
    29552956    {
    2956         event.Event_Subtitle = event.Description.left(position);
    2957         event.Description = event.Description.mid(position+1);
    2958         if ((event.Event_Subtitle.length() > 0) &&
    2959             (event.Description.length() > 0) &&
    2960             (event.Event_Subtitle.length() > event.Description.length()))
     2957        // if the subtitle is less than 50% of the description use it.
     2958        if ((position*100)/event.Description.length() < SUBTITLE_PCT)
    29612959        {
    2962             QString Temp = event.Event_Subtitle;
    2963             event.Event_Subtitle = event.Description;
    2964             event.Description = Temp;
     2960            event.Event_Subtitle = event.Description.left(position);
     2961            event.Description = event.Description.mid(position+1);
    29652962        }
    29662963    }
     2964    else if ((position = event.Description.find(terminatesWith)) != -1)
     2965    {
     2966        if ((position*100)/event.Description.length() < SUBTITLE_PCT)
     2967        {
     2968            event.Event_Subtitle = event.Description.left(position+1);
     2969            event.Description = event.Description.mid(position+2);
     2970        }
     2971    }
    29672972
     2973    QRegExp endsWith("\\.+$");
     2974    QRegExp startsWith("^\\.+");
     2975    terminatesWith.setPattern("[:\\!\\.\\?]");
    29682976    if (event.Event_Name.endsWith("...") &&
    29692977        event.Event_Subtitle.startsWith(".."))
    29702978    {
    29712979        //try and make the subtitle
    2972         QString Full = event.Event_Name.left(event.Event_Name.length()-3)+" ";
     2980        QString Full = event.Event_Name.replace(endsWith,"")+" "+
     2981                       event.Event_Subtitle.replace(startsWith,"");
    29732982
    2974         if (event.Event_Subtitle.startsWith("..."))
    2975             Full += event.Event_Subtitle.mid(3);
    2976         else
    2977             Full += event.Event_Subtitle.mid(2);
    2978         if (((position = Full.find(":")) != -1) ||
    2979             ((position = Full.find(".")) != -1))
     2983        if ((position = Full.find(terminatesWith)) != -1)
    29802984        {
     2985           if (Full[position] == '!' || Full[position] == '?')
     2986               position++;
    29812987           event.Event_Name = Full.left(position);
    29822988           event.Event_Subtitle = Full.mid(position+1);
    29832989        }
     
    29902996    else if (event.Event_Subtitle.endsWith("...") &&
    29912997        event.Description.startsWith("..."))
    29922998    {
    2993          QString Full = event.Event_Subtitle.left(event.Event_Subtitle.length()
    2994                         -3)+" "+ event.Description.mid(3);
    2995         if (((position = Full.find(":")) != -1) ||
    2996             ((position = Full.find(".")) != -1))
     2999        QString Full = event.Event_Subtitle.replace(endsWith,"")+" "+
     3000                       event.Description.replace(startsWith,"");
     3001        if ((position = Full.find(terminatesWith)) != -1)
    29973002        {
     3003           if (Full[position] == '!' || Full[position] == '?')
     3004               position++;
    29983005           event.Event_Subtitle = Full.left(position);
    29993006           event.Description = Full.mid(position+1);
    30003007        }
     
    30023009    else if (event.Event_Name.endsWith("...") &&
    30033010        event.Description.startsWith("...") && event.Event_Subtitle.isEmpty())
    30043011    {
    3005         QString Full = event.Event_Name.left(event.Event_Name.length()
    3006                         -3)+" "+ event.Description.mid(3);
    3007         if (((position = Full.find(":")) != -1) ||
    3008             ((position = Full.find(".")) != -1))
     3012        QString Full = event.Event_Name.replace(endsWith,"")+" "+
     3013                       event.Description.replace(startsWith,"");
     3014        if ((position = Full.find(terminatesWith)) != -1)
    30093015        {
     3016           if (Full[position] == '!' || Full[position] == '?')
     3017               position++;
    30103018           event.Event_Name = Full.left(position);
    30113019           event.Description = Full.mid(position+1);
    30123020        }
     
    30143022
    30153023    //Work out the episode numbers (if any)
    30163024    bool series = false;
    3017     QRegExp rx("^\\s*(\\d{1,2})/(\\d{1,2})\\.");
     3025    rx.setPattern("^\\s*(\\d{1,2})/(\\d{1,2})\\.");
    30183026    QRegExp rx1("\\((Part|Pt)\\s+(\\d{1,2})\\s+of\\s+(\\d{1,2})\\)");
     3027    rx1.setCaseSensitive(FALSE);
    30193028    if ((position = rx.search(event.Event_Name)) != -1)
    30203029    {
    30213030        event.PartNumber=rx.cap(1).toUInt();
     
    33133322
    33143323void SIParser::InitializeCategories()
    33153324{
    3316     m_mapCategories[0x10] = tr("Movies");
     3325    m_mapCategories[0x10] = tr("Movie");
    33173326    m_mapCategories[0x11] = tr("Movie") + " - " +
    33183327        tr("Detective/Thriller");
    33193328    m_mapCategories[0x12] = tr("Movie")+ " - " +