diff options
Diffstat (limited to 'eepg.c')
-rw-r--r-- | eepg.c | 97 |
1 files changed, 89 insertions, 8 deletions
@@ -121,7 +121,9 @@ cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void) Add (new cMenuEditBoolItem (tr ("Show order information"), &data->OrderInfo)); Add (new cMenuEditBoolItem (tr ("Show rating information"), &data->RatingInfo)); Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data->FixEpg)); + SetSection (tr ("General")); Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage)); + Add (new cMenuEditBoolItem (tr ("Replace Empty Short Text with Category - Genre"), &data->ReplaceEmptyShText)); #ifdef DEBUG Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data->LogLevel, 0, 5)); Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data->ProcessEIT)); @@ -136,6 +138,7 @@ void cMenuSetupPremiereEpg::Store (void) SetupStore ("RatingInfo", SetupPE->RatingInfo); SetupStore ("FixEpg", SetupPE->FixEpg); SetupStore ("DisplayMessage", SetupPE->DisplayMessage); + SetupStore ("ReplaceEmptyShText", SetupPE->ReplaceEmptyShText); #ifdef DEBUG SetupStore ("LogLevel", SetupPE->LogLevel); SetupStore ("ProcessEIT", SetupPE->ProcessEIT); @@ -222,7 +225,7 @@ protected: //virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); virtual void WriteToSchedule (tChannelID channelID, cSchedules* s, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, - unsigned short int TableId, unsigned short int Version, char Rating = 0x00); + unsigned short int TableId, unsigned short int Version, char Rating = 0x00, unsigned char ShortTextLenght = 0); virtual void LoadIntoSchedule (void); //virtual void LoadEquivalentChannels (void); @@ -266,6 +269,13 @@ void cFilterEEPG::SetStatus (bool On) for (int i = 0; i <= HIGHEST_FORMAT; i++) UnprocessedFormat[i] = 0; //pid 0 is assumed to be nonvalid for EEPG transfers AddFilter (0, 0); + if (Channel()->Nid() == 0x01) { + setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); + LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); + } else { + unsetenv("VDR_CHARSET_OVERRIDE"); + LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); + } } cFilter::SetStatus (On); Trigger (); @@ -1235,7 +1245,11 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse * \param Duration the Duration of the event in minutes * \param ps points to array of schedules ps[eq], where eq is equivalence number of the channel. If channelId is invalid then ps[eq]=NULL */ -void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text, char *SummText, unsigned short int ThemeId, unsigned short int TableId, unsigned short int Version, char Rating) +void cFilterEEPG::WriteToSchedule(tChannelID channelID, cSchedules* pSchedules, + unsigned int EventId, unsigned int StartTime, unsigned int Duration, + char *Text, char *SummText, unsigned short int ThemeId, + unsigned short int TableId, unsigned short int Version, char Rating, + unsigned char ShTxtLen) { bool WrittenTitle = false; bool WrittenSummary = false; @@ -1277,21 +1291,66 @@ void cFilterEEPG::WriteToSchedule (tChannelID channelID, cSchedules* pSchedules, if (Rating) { Event->SetParentalRating(Rating); } - char *tmp; if (Text != 0x00) { WrittenTitle = true; CleanString ((uchar *) Text); Event->SetTitle (Text); } - Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); - Event->SetShortText (tmp); - free(tmp); + + char* tmp = NULL; + string shText; + if (SummText && ShTxtLen) { + + shText.assign(SummText,ShTxtLen); + + string tmpTitle(Text); + if (Format == MHW2 && !shText.empty()) { + //TODO (HD) channels + size_t found = tmpTitle.find(" (HD)"); + if (found != string::npos) + tmpTitle.erase(found, 5); + found = shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": ")); + if (shText.compare(0, tmpTitle.size() + 2, string(tmpTitle + ": "))==0) + shText.erase(0, tmpTitle.size() + 2); + } + + //Do not use Subtitle if it is substring of Title + if (tmpTitle.compare(0, shText.size(), shText) == 0) + shText.clear(); + +#define MAX_USEFUL_EPISODE_LENGTH 40 + // From VDR FixEPG Bugs + // Some channels put a whole lot of information in the ShortText and leave + // the Description totally empty. So if the ShortText length exceeds + // MAX_USEFUL_EPISODE_LENGTH, let's put this into the Description + // instead: + if (!shText.empty() && shText.size() > MAX_USEFUL_EPISODE_LENGTH) + shText.clear(); + + } + if (!shText.empty()) + Event->SetShortText (shText.c_str()); + else if (SetupPE->ReplaceEmptyShText) { + Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); + Event->SetShortText (tmp); + free(tmp); + } +/* + char *tmp; + if (!ShortText || strcmp(ShortText, Text) == 0) { + Asprintf (&tmp, "%s - %d\'", Themes[ThemeId], Duration); + Event->SetShortText (tmp); + free(tmp); + } else + Event->SetShortText (ShortText); +*/ //strreplace(t, '|', '\n'); if (SummText != 0x00) { WrittenSummary = true; CleanString ((uchar *) SummText); //Add themes and categories epgsearch style + //TODO DPE move this char *theme; Asprintf (&theme, "%s", Themes[ThemeId]); if (theme && 0 != strcmp(theme,"")) { @@ -2008,6 +2067,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length) S->NumReplays = Summary->NumReplays; S->EventId = HILO32 (Summary->ProgramId); S->Text = Text; + S->ShortTextLength = 0; //TODO find for MHW1 int i = 0; do { S->Replays[i].MjdTime = 0; //only used for SKY @@ -2126,6 +2186,9 @@ int cFilterEEPG::GetSummariesMHW2 (const u_char * Data, int Length) //S->Text[SummaryLength] = '\0'; //end string with NULL character decodeText2(tmp,SummaryLength,(char*)S->Text,2 * SummaryLength + 1); CleanString (S->Text); + char * delim = strchr ( (char *)S->Text, '\n' ); + S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; + LogI(3, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); nSummaries++; } else { @@ -2349,6 +2412,7 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) unsigned short int MjdTime; int Len1; int Len2; + const char* STxtDelim = Format == SKY_UK?": ":" - "; if (Length < 20) { return 1; //non fatal error I assume @@ -2372,6 +2436,7 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) S->Replays[0].MjdTime = MjdTime; S->NumReplays = 0; //not used S->EventId = (Data[p] << 8) | Data[p + 1]; + S->ShortTextLength = 0; Len1 = ((Data[p + 2] & 0x0f) << 8) | Data[p + 3]; if (Data[p + 4] != 0xb9) { LogD(5, prep("Data error signature for title - Data[p + 4] != 0xb5")); @@ -2397,6 +2462,8 @@ int cFilterEEPG::GetSummariesSKYBOX (const u_char * Data, int Length) memcpy (S->Text, tmp, Len2); S->Text[Len2] = '\0'; //end string with NULL character CleanString (S->Text); + char * delim = strstr ( (char *)S->Text, STxtDelim ); + S->ShortTextLength = delim == NULL ? 0 : delim - (char *)S->Text; LogI(3, prep("EventId %08x Summnr %d:%.30s."), S->EventId, nSummaries, S->Text); p += Len1; nSummaries++; @@ -2518,9 +2585,13 @@ void cFilterEEPG::LoadIntoSchedule (void) TableId = T->TableId; } +// LogD (0, prep("EventId %08x Titlenr %d:SummAv:%x,Un1:%x,Un2:%x,Un3:%x,Name:%s,STxtLn:%dSummary:%s."), +// T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text, S->ShortTextLength, S->Text); + WriteToSchedule (chanID, s, T->EventId, StartTime, T->Duration / 60, (char *) T->Text, - (char *) S->Text, T->ThemeId, TableId, 0, rating); + (char *) S->Text, T->ThemeId, TableId, 0, rating, S->ShortTextLength); sortSchedules(s, chanID); + //if (shortText != NULL) delete [] shortText; //FinishWriteToSchedule (C, s, p); //Replays--; @@ -2563,7 +2634,7 @@ void cFilterEEPG::LoadIntoSchedule (void) rating = T->Rating; } WriteToSchedule (chanID, s, T->EventId, T->StartTime, T->Duration / 60, (char *) T->Text, - NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating); + NULL, T->ThemeId, DEFAULT_TABLE_ID, 0, rating, S->ShortTextLength); //FinishWriteToSchedule (C, s, p); sortSchedules(s, chanID); @@ -2774,6 +2845,14 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len // LogD(2, prep("Pid: 0x%02x Tid: %d Length: %d PMT pid: 0x%04x"), Pid, Tid, Length, pmtpid); // LogD(2, prep("Source: %d Transponder: %d"), Source () , Transponder ()); + if (Channel()->Nid() == 0x01) { + setenv("VDR_CHARSET_OVERRIDE", "ISO-8859-9", true); + LogD(0, prep("setenv VDR_CHARSET_OVERRIDE ISO-8859-9")); + } + else { + unsetenv("VDR_CHARSET_OVERRIDE"); + LogD(0, prep("clear VDR_CHARSET_OVERRIDE")); + } if (Pid == 0 && Tid == SI::TableIdPAT) { if (!pmtnext || now > pmtnext) { if (pmtpid) @@ -3619,6 +3698,8 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value) SetupPE->FixEpg = atoi (Value); else if (!strcasecmp (Name, "DisplayMessage")) SetupPE->DisplayMessage = atoi (Value); + else if (!strcasecmp (Name, "ReplaceEmptyShText")) + SetupPE->ReplaceEmptyShText = atoi (Value); #ifdef DEBUG else if (!strcasecmp (Name, "LogLevel")) SetupPE->LogLevel = atoi (Value); |