Ticket #1321: uk-eit-guide-fixups.diff

File uk-eit-guide-fixups.diff, 1.9 KB (added by Stuart Auchterlonie, 14 years ago)

Additional UK EIT fixes.

  • libs/libmythtv/eitfixup.cpp

    old new  
    130130 */
    131131void EITFixUp::FixStyle2(Event &event)
    132132{
    133     const uint SUBTITLE_PCT = 50; //% of description to allow subtitle up to
     133    const uint SUBTITLE_PCT = 35; //% of description to allow subtitle up to
     134    const uint16_t SUBTITLE_MAX_LEN = 128; // max length of subtitle field in db.
    134135    int position = event.Description.find("New Series");
    135136    if (position != -1)
    136137    {
    137138        //Do something here
    138139    }
     140    QRegExp sub("\\[.*S\\]");
     141    position = event.Description.find(sub);
     142    if (position != -1)
     143    {
     144        event.SubTitled=true;
     145    }
     146
    139147    //BBC three case (could add another record here ?)
    140148    QRegExp rx("\\s*(Then|Followed by) 60 Seconds\\.");
    141149    rx.setCaseSensitive(false);
     
    160168    else if ((position = event.Description.find(":")) != -1)
    161169    {
    162170        // if the subtitle is less than 50% of the description use it.
    163         if ((position*100)/event.Description.length() < SUBTITLE_PCT)
     171        if ((position < SUBTITLE_MAX_LEN) &&
     172            ((position*100)/event.Description.length() < SUBTITLE_PCT))
    164173        {
    165174            event.Event_Subtitle = event.Description.left(position);
    166175            event.Description = event.Description.mid(position+1);
     
    168177    }
    169178    else if ((position = event.Description.find(terminatesWith)) != -1)
    170179    {
    171         if ((position*100)/event.Description.length() < SUBTITLE_PCT)
     180        if ((position < SUBTITLE_MAX_LEN) &&
     181            ((position*100)/event.Description.length() < SUBTITLE_PCT))
    172182        {
    173183            event.Event_Subtitle = event.Description.left(position+1);
    174184            event.Description = event.Description.mid(position+2);