Ticket #270: eit.patch

File eit.patch, 13.0 KB (added by John Pullan <john.pullan@…>, 19 years ago)

Update to the uk EIT parsing

  • libs/libmythtv/siparser.cpp

     
    14331433                    break;
    14341434
    14351435                case 0x54:
    1436                     e.ContentDescription =
    1437                             ProcessContentDescriptor(
    1438                                 &buffer[des_pos],buffer[des_pos+1]+2);
     1436                    ProcessContentDescriptor(
     1437                        &buffer[des_pos],buffer[des_pos+1]+2,e);
    14391438                    break;
    14401439
    14411440                default:           
     
    19521951 *  \TODO Add all types, possibly just lookup from a big
    19531952 *        array that is an include file?
    19541953 */
    1955 QString SIParser::ProcessContentDescriptor(uint8_t *buf, int)
     1954void SIParser::ProcessContentDescriptor(uint8_t *buf, int, Event& e)
    19561955{
    19571956    uint8_t content = buf[2];
    19581957    if (content)
    1959         return m_mapCategories[content];
    1960     else
    1961         return QString();
     1958    {
     1959        e.ContentDescription = m_mapCategories[content];
     1960        switch (content)
     1961        {
     1962        case 0x10 ... 0x1f:
     1963            e.CategoryType = "movie";
     1964            break;
     1965        case 0x40 ... 0x4f:
     1966            e.CategoryType = "sports";
     1967            break;
     1968        default:
     1969            e.CategoryType = "tvshow";
     1970        }     
     1971    }
    19621972}
    19631973
    19641974/**
     
    29222932    event.Description = event.Description.replace("New Series","");
    29232933
    29242934
    2925     position = event.Description.find(':');
    2926     if (position != -1)
     2935    //This is trying to catch the case where the subtitle is in the main title
     2936    //but avoid cases where it isn't a subtitle e.g cd:uk
     2937    if (((position = event.Event_Name.find(":")) != -1) &&
     2938        (event.Description.find(":") == -1) &&
     2939        (event.Event_Name[position+1].upper()==event.Event_Name[position+1]))
    29272940    {
     2941        event.Event_Subtitle = event.Event_Name.mid(position+1);
     2942        event.Event_Name = event.Event_Name.left(position);
     2943    }
     2944    else if ((position = event.Description.find(":")) != -1)
     2945    {
    29282946        event.Event_Subtitle = event.Description.left(position);
    2929         event.Description = event.Description.right(
    2930             event.Description.length()-position-2);
     2947        event.Description = event.Description.mid(position+1);
    29312948        if ((event.Event_Subtitle.length() > 0) &&
    29322949            (event.Description.length() > 0) &&
    29332950            (event.Event_Subtitle.length() > event.Description.length()))
     
    29392956    }
    29402957
    29412958    if (event.Event_Name.endsWith("...") &&
    2942         event.Event_Subtitle.startsWith("..."))
     2959        event.Event_Subtitle.startsWith(".."))
    29432960    {
    29442961        //try and make the subtitle
    2945         QString Full = event.Event_Name.left(event.Event_Name.length()-3)+" "+
    2946             event.Event_Subtitle.right(event.Event_Subtitle.length()-3);
    2947         if ((position = Full.find(":")) != -1)
     2962        QString Full = event.Event_Name.left(event.Event_Name.length()-3)+" ";
     2963
     2964        if (event.Event_Subtitle.startsWith("..."))
     2965            Full += event.Event_Subtitle.mid(3);
     2966        else
     2967            Full += event.Event_Subtitle.mid(2);
     2968        if (((position = Full.find(":")) != -1) ||
     2969            ((position = Full.find(".")) != -1))
    29482970        {
    29492971           event.Event_Name = Full.left(position);
    2950            event.Event_Subtitle = Full.right(Full.length()-position-2);
     2972           event.Event_Subtitle = Full.mid(position+1);
    29512973        }
    2952         else if ((position = Full.find(".")) != -1)
     2974        else
    29532975        {
     2976           event.Event_Name = Full;
     2977           event.Event_Subtitle="";
     2978        }
     2979    }
     2980    else if (event.Event_Subtitle.endsWith("...") &&
     2981        event.Description.startsWith("..."))
     2982    {
     2983         QString Full = event.Event_Subtitle.left(event.Event_Subtitle.length()
     2984                        -3)+" "+ event.Description.mid(3);
     2985        if (((position = Full.find(":")) != -1) ||
     2986            ((position = Full.find(".")) != -1))
     2987        {
     2988           event.Event_Subtitle = Full.left(position);
     2989           event.Description = Full.mid(position+1);
     2990        }
     2991    }
     2992    else if (event.Event_Name.endsWith("...") &&
     2993        event.Description.startsWith("...") && event.Event_Subtitle.isEmpty())
     2994    {
     2995        QString Full = event.Event_Name.left(event.Event_Name.length()
     2996                        -3)+" "+ event.Description.mid(3);
     2997        if (((position = Full.find(":")) != -1) ||
     2998            ((position = Full.find(".")) != -1))
     2999        {
    29543000           event.Event_Name = Full.left(position);
    2955            event.Event_Subtitle = Full.right(Full.length()-position-2);
     3001           event.Description = Full.mid(position+1);
    29563002        }
    29573003    }
     3004
     3005    //Work out the episode numbers (if any)
     3006    bool series = false;
     3007    QRegExp rx("^\\s*(\\d{1,2})/(\\d{1,2})\\.");
     3008    QRegExp rx1("\\((Part|Pt)\\s+(\\d{1,2})\\s+of\\s+(\\d{1,2})\\)");
     3009    if ((position = rx.search(event.Event_Name)) != -1)
     3010    {
     3011        event.PartNumber=rx.cap(1).toUInt();
     3012        event.PartTotal=rx.cap(2).toUInt();
     3013        //Remove from the title
     3014        event.Event_Name=event.Event_Name.mid(position+rx.cap(0).length());
     3015        //but add it to the description
     3016        event.Description+=rx.cap(0);
     3017        series=true;
     3018    }
     3019    else if ((position = rx.search(event.Event_Subtitle)) != -1)
     3020    {
     3021        event.PartNumber=rx.cap(1).toUInt();
     3022        event.PartTotal=rx.cap(2).toUInt();
     3023        //Remove from the sub title
     3024        event.Event_Subtitle=event.Event_Subtitle.mid(position+rx.cap(0).length());
     3025        //but add it to the description
     3026        event.Description+=rx.cap(0);
     3027        series=true;
     3028    }
     3029    else if ((position = rx.search(event.Description)) != -1)
     3030    {
     3031        event.PartNumber=rx.cap(1).toUInt();
     3032        event.PartTotal=rx.cap(2).toUInt();
     3033        //Don't cut it from the description
     3034        //event.Description=event.Description.left(position)+
     3035        //                  event.Description.mid(position+rx.cap(0).length());
     3036        series=true;
     3037    }
     3038    else if ((position = rx1.search(event.Description)) != -1)
     3039    {
     3040        event.PartNumber=rx1.cap(2).toUInt();
     3041        event.PartTotal=rx1.cap(3).toUInt();
     3042        //Don't cut it from the description
     3043        //event.Description=event.Description.left(position)+
     3044        //                  event.Description.mid(position+rx1.cap(0).length());
     3045        series=true;
     3046    }
     3047    if (series)
     3048        event.CategoryType="series";
     3049    //Work out the closed captions and Audio descriptions  (if any)
     3050    rx.setPattern("\\[(AD)(,(S)){,1}(,SL){,1}\\]|"
     3051               "\\[(S)(,AD){,1}(,SL){,1}\\]|"
     3052               "\\[(SL)(,AD){,1}(,(S)){,1}\\]");
     3053    if ((position = rx.search(event.Description)) != -1)
     3054    {
     3055        //Enumerate throught and see if we have subtitles, don't modify
     3056        //the description as we might destroy other useful information
     3057        QStringList captures = rx.capturedTexts();
     3058        QStringList::Iterator i = captures.begin();
     3059        QStringList::Iterator end = captures.end();
     3060        while (i!=end)
     3061            if (*(i++) == "S")
     3062                 event.SubTitled = true;
     3063    }
     3064    else if ((position = rx.search(event.Event_Subtitle)) != -1)
     3065    {
     3066        QStringList captures = rx.capturedTexts();
     3067        QStringList::Iterator i = captures.begin();
     3068        QStringList::Iterator end = captures.end();
     3069        while (i!=end)
     3070            if (*(i++) == "S")
     3071                 event.SubTitled = true;
     3072        //We do remove [AD,S] from the subtitle as it probably shouldn't be
     3073        //there.
     3074        QString Temp = event.Event_Subtitle;
     3075        event.Event_Subtitle = Temp.left(position)+Temp.mid(position+rx.cap(0).length());
     3076    }
     3077    //Work out the year (if any)
     3078    rx.setPattern("[\\[\\(]([\\d]{4})[\\)\\]]");
     3079    if ((position = rx.search(event.Description)) != -1)
     3080    {
     3081        event.Description=event.Description.left(position)+
     3082                          event.Description.mid(position+rx.cap(0).length());
     3083        event.Year=rx.cap(1);
     3084    }
     3085
     3086    event.Event_Name = event.Event_Name.stripWhiteSpace();
     3087    event.Event_Subtitle = event.Event_Subtitle.stripWhiteSpace();
     3088    event.Description = event.Description.stripWhiteSpace();
    29583089}
    29593090
    29603091void SIParser::EITFixUpStyle3(Event &event)
  • libs/libmythtv/sitypes.h

     
    353353    //bool PreviouslyShown;
    354354    QDate OriginalAirDate;
    355355    QValueList<Person> Credits;
     356    unsigned PartNumber;
     357    unsigned PartTotal;
     358    QString  CategoryType;
    356359};
    357360
    358361// DVB TransportObject - Used with NIT Scanning
  • libs/libmythtv/dbcheck.cpp

     
    192192and must be selected when you compile %MythTV. Finally, the 'atscsrcid'
    193193field currently contains both the major and minor atsc channels, encoded
    194194in the form (majorChannel * 256 | minorChannel) when using DVB drivers.
     195
     196\section program_table Program Entry Table (program)
     197'category_type' holds one of these exact four strings: "movie", "series", "sports" or "tvshow".
     198
     199'airdate' is a string representing the year of release for movies and may have no meaning for other types of shows.
     200
     201'stars' is a floating point number from 0.0 to 1.0. On a four star scale, 1.0 would be four stars, 0.75 would be three stars and so on.
     202
     203'originalairdate' if provided is the date when a show was, or will be, first televised.
     204
     205'previouslyshown' is a field created by MythTV to try to determine if a showing is more than 14 days after its original air date or if the show was marked as a repeat and did not have a date for the first airing. If this is "0" it usually means that this is a brand new show or a rebroadcast within the first two weeks.
     206
     207'programid' is the Tribune Media Service database record identifier for each program description. In general, these start with a two letter prefix, MV, EP, SP or SH that equate to the 'category_type'. For most, the last four digits are "0000" except EP where the last four digits are the episode number in the series. Note that these are generated by TMS and not the show's producers but they are usually in the same order as the original air dates for the episodes. Detailed information can be found in the Data Direct documentation at http://labs.zap2it.com/ .
     208
    195209 */
    196210
    197211/** \fn UpdateDBVersionNumber(const QString&)
  • libs/libmythtv/eithelper.cpp

     
    223223    query.prepare("REPLACE INTO program (chanid, starttime, "
    224224                  "endtime, title, description, subtitle, "
    225225                  "category, stereo, closecaptioned, hdtv, "
    226                   "airdate, originalairdate) "
     226                  "airdate, originalairdate, partnumber, parttotal, "
     227                  "category_type) "
    227228                  "VALUES (:CHANID, :STARTTIME, "
    228229                  ":ENDTIME, :TITLE, :DESCRIPTION, :SUBTITLE, "
    229230                  ":CATEGORY, :STEREO, :CLOSECAPTIONED, :HDTV, "
    230                   ":AIRDATE, :ORIGINALAIRDATE);");
     231                  ":AIRDATE, :ORIGINALAIRDATE, :PARTNUMBER, :PARTTOTAL,"
     232                  ":CATTYPE);");
    231233    query.bindValue(":CHANID", chanid);
    232234    query.bindValue(":STARTTIME", event.StartTime.
    233235                    toString(QString("yyyy-MM-dd hh:mm:00")));
     
    243245    query.bindValue(":AIRDATE", event.Year);
    244246    query.bindValue(":ORIGINALAIRDATE", event.OriginalAirDate.
    245247                    toString(QString("yyyy-MM-dd")));
     248    query.bindValue(":PARTNUMBER", event.PartNumber);
     249    query.bindValue(":PARTTOTAL", event.PartTotal);
     250    query.bindValue(":CATTYPE", event.CategoryType.utf8());
    246251
    247252    if (!query.exec() || !query.isActive())
    248253    {
  • libs/libmythtv/sitypes.cpp

     
    251251    Stereo = false;
    252252    HDTV = false;
    253253    ATSC = false;
     254    PartNumber = 0;
     255    PartTotal = 0;
     256    CategoryType="";
    254257    //PreviouslyShown = false;
    255258    OriginalAirDate = QDate();
    256259    Credits.clear();
  • libs/libmythtv/siparser.h

     
    162162    QString ProcessDescHuffmanTextLarge      (uint8_t *buf, uint sz);
    163163
    164164    // DVB EIT Table Descriptor processors
    165     QString ProcessContentDescriptor         (uint8_t *buf, int sz);
     165    void ProcessContentDescriptor            (uint8_t *buf, int sz, Event &e);
    166166    void ProcessShortEventDescriptor         (uint8_t *buf, int sz, Event &e);
    167167    void ProcessExtendedEventDescriptor      (uint8_t *buf, int sz, Event &e);
    168168    void ProcessComponentDescriptor          (uint8_t *buf, int sz, Event &e);