#!/bin/sh /usr/share/dpatch/dpatch-run ## disableDoubleEpgEntrys patch - by Emanuel Wontorra ## ## downloaded from http://www.wontorra.net/filemgmt/visit.php?lid=61 ## original filename disableDoubleEpgEntrys_0.7.1.tar.gz ## ## Fixed memory leak by Thomas Günther : ## http://toms-cafe.de/vdr/download/vdr-disableDoubleEpgEntrys_0.7.1_fix-leak.diff ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: This patch suppresses double EPG entries. @DPATCH@ --- vdr-1.3.18.org/config.c 2005-01-09 13:14:58.000000000 +0100 +++ vdr-1.3.18/config.c 2005-01-15 10:26:32.000000000 +0100 @@ -295,6 +295,10 @@ MinUserInactivity = 120; MultiSpeedMode = 0; ShowReplayMode = 0; + DoubleEpgTimeDelta = 15; + DoubleEpgAction = 0; + MixEpgAction = 0; + DisableVPS = 0; ResumeID = 0; CurrentChannel = -1; CurrentVolume = MAXVOLUME; @@ -450,6 +454,10 @@ else if (!strcasecmp(Name, "MinUserInactivity")) MinUserInactivity = atoi(Value); else if (!strcasecmp(Name, "MultiSpeedMode")) MultiSpeedMode = atoi(Value); else if (!strcasecmp(Name, "ShowReplayMode")) ShowReplayMode = atoi(Value); + else if (!strcasecmp(Name, "DoubleEpgTimeDelta")) DoubleEpgTimeDelta = atoi(Value); + else if (!strcasecmp(Name, "DoubleEpgAction")) DoubleEpgAction = atoi(Value); + else if (!strcasecmp(Name, "MixEpgAction")) MixEpgAction = atoi(Value); + else if (!strcasecmp(Name, "DisableVPS")) DisableVPS = atoi(Value); else if (!strcasecmp(Name, "ResumeID")) ResumeID = atoi(Value); else if (!strcasecmp(Name, "CurrentChannel")) CurrentChannel = atoi(Value); else if (!strcasecmp(Name, "CurrentVolume")) CurrentVolume = atoi(Value); @@ -510,6 +518,10 @@ Store("SplitEditedFiles", SplitEditedFiles); Store("MinEventTimeout", MinEventTimeout); Store("MinUserInactivity", MinUserInactivity); + Store("DoubleEpgAction", DoubleEpgAction); + Store("MixEpgAction", MixEpgAction); + Store("DisableVPS", DisableVPS); + Store("DoubleEpgTimeDelta", DoubleEpgTimeDelta); Store("MultiSpeedMode", MultiSpeedMode); Store("ShowReplayMode", ShowReplayMode); Store("ResumeID", ResumeID); diff -Nur vdr-1.3.18.org/config.h vdr-1.3.18/config.h --- vdr-1.3.18.org/config.h 2005-01-09 13:14:34.000000000 +0100 +++ vdr-1.3.18/config.h 2005-01-15 10:26:32.000000000 +0100 @@ -249,6 +249,10 @@ int MinEventTimeout, MinUserInactivity; int MultiSpeedMode; int ShowReplayMode; + int DoubleEpgTimeDelta; + int DoubleEpgAction; + int MixEpgAction; + int DisableVPS; int ResumeID; int CurrentChannel; int CurrentVolume; diff -Nur vdr-1.3.18.org/eit.c vdr-1.3.18/eit.c --- vdr-1.3.18.org/eit.c 2005-01-02 12:52:12.000000000 +0100 +++ vdr-1.3.18/eit.c 2005-01-15 10:33:41.000000000 +0100 @@ -63,7 +63,83 @@ // If the existing event has a zero table ID it was defined externally and shall // not be overwritten. if (pEvent->TableID() == 0x00) - continue; + { + if(Setup.MixEpgAction == 0) + continue; + + //printf("in"); + //printf("%s", pEvent->GetTimeString()); + // to use the info of the original epg, update the extern one, + // if it has less info + SI::Descriptor *d; + SI::ExtendedEventDescriptors *ExtendedEventDescriptors = NULL; + //SI::ExtendedEventDescriptor *eed = NULL; + SI::ShortEventDescriptor *ShortEventDescriptor = NULL; + //SI::ShortEventDescriptor *sed = NULL; + //SI::TimeShiftedEventDescriptor *tsed = NULL; + //cLinkChannels *LinkChannels = NULL; + for (SI::Loop::Iterator it2; (d = SiEitEvent.eventDescriptors.getNext(it2));) + { + if(d->getDescriptorTag() == SI::ShortEventDescriptorTag) + { + int LanguagePreferenceShort = -1; + SI::ShortEventDescriptor *sed = (SI::ShortEventDescriptor *)d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, I18nLanguageIndex(sed->languageCode), LanguagePreferenceShort) || !ShortEventDescriptor) + { + delete ShortEventDescriptor; + ShortEventDescriptor = sed; + d = NULL; // so that it is not deleted + } + } + else if(d->getDescriptorTag() == SI::ExtendedEventDescriptorTag) + { + int LanguagePreferenceExt = -1; + bool UseExtendedEventDescriptor = false; + SI::ExtendedEventDescriptor *eed = (SI::ExtendedEventDescriptor *)d; + if (I18nIsPreferredLanguage(Setup.EPGLanguages, I18nLanguageIndex(eed->languageCode), LanguagePreferenceExt) || !ExtendedEventDescriptors) + { + delete ExtendedEventDescriptors; + ExtendedEventDescriptors = new SI::ExtendedEventDescriptors; + UseExtendedEventDescriptor = true; + } + if (UseExtendedEventDescriptor) + { + ExtendedEventDescriptors->Add(eed); + d = NULL; // so that it is not deleted + } + if (eed->getDescriptorNumber() == eed->getLastDescriptorNumber()) + UseExtendedEventDescriptor = false; + } + delete d; + } + if(pEvent) + { + + if(ShortEventDescriptor) + { + char buffer[256]; + if(ShortEventDescriptor->text.getText(buffer, sizeof(buffer)) && pEvent->ShortText() && (strlen(ShortEventDescriptor->text.getText(buffer, sizeof(buffer))) > strlen(pEvent->ShortText()))) + { + pEvent->SetShortText(ShortEventDescriptor->text.getText(buffer, sizeof(buffer))); + //printf("%s\n", ShortEventDescriptor->text.getText(buffer, sizeof(buffer))); + } + } + if(ExtendedEventDescriptors) + { + char buffer[ExtendedEventDescriptors->getMaximumTextLength(": ") + 1]; + //pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": ")); + + if(ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": ") && pEvent->Description() && (strlen(ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": ")) > strlen(pEvent->Description()))) + { + pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": ")); + //printf("%s", ExtendedEventDescriptors->getText(buffer, sizeof(buffer), ": ")); + } + } + } + delete ExtendedEventDescriptors; + delete ShortEventDescriptor; + continue; + } // If the new event has a higher table ID, let's skip it. // The lower the table ID, the more "current" the information. if (Tid > pEvent->TableID()) @@ -234,14 +309,88 @@ else pEvent->SetComponents(NULL); - pEvent->FixEpgBugs(); + pEvent->FixEpgBugs(); if (LinkChannels) channel->SetLinkChannels(LinkChannels); if (Tid == 0x4E) { // we trust only the present/following info on the actual TS - if (SiEitEvent.getRunningStatus() >= SI::RunningStatusNotRunning) + if (Setup.DisableVPS == 0 && SiEitEvent.getRunningStatus() >= SI::RunningStatusNotRunning) pSchedule->SetRunningStatus(pEvent, SiEitEvent.getRunningStatus(), channel); } Modified = true; + + //to avoid double epg-entrys from ext and int epg sources :EW + if (pEvent && pEvent->TableID() != 0x00) + { + cEvent *pPreviousEvent = (cEvent *)pSchedule->GetPreviousEvent(pEvent); + + if (pPreviousEvent) + { + if(Setup.DoubleEpgAction == 0) + { + pPreviousEvent->SetStartTime(pEvent->StartTime()); + pPreviousEvent->SetDuration(pEvent->Duration()); + + if(Setup.DisableVPS == 0 && pPreviousEvent->RunningStatus() == 0 && pEvent->RunningStatus() != 0) + { + if(channel) + pPreviousEvent->SetRunningStatus(pEvent->RunningStatus(), channel); + else + pPreviousEvent->SetRunningStatus(pEvent->RunningStatus()); + } + + // to use the info of the original epg, update the extern one, + // if it has less info + char buffer_short_intern[256]; + char buffer_short_extern[256]; + int len_short_intern = 0; + int len_short_extern = 0; + + if (pEvent->ShortText()) + len_short_intern = sprintf (buffer_short_intern, "%s", pEvent->ShortText()); + + if (pPreviousEvent->ShortText()) + len_short_extern = sprintf (buffer_short_extern, "%s",pPreviousEvent->ShortText()); + + if(len_short_intern > 0) + { + if(len_short_extern < 1) + pPreviousEvent->SetShortText(buffer_short_intern); + else if (len_short_intern > len_short_extern) + pPreviousEvent->SetShortText(buffer_short_intern); + } + + if(pEvent->Description()) + { + char buffer_title_intern[4096]; + char buffer_title_extern[4096]; + int len_title_intern = 0; + int len_title_extern = 0; + + if (pEvent->Description()) + len_title_intern = sprintf (buffer_title_intern, "%s", pEvent->Description()); + + if (pPreviousEvent->Description()) + len_title_extern = sprintf (buffer_title_extern, "%s", pPreviousEvent->Description()); + + if(len_title_intern > 0) + { + if(len_title_extern < 1) + pPreviousEvent->SetDescription(buffer_title_intern); + else if (len_title_intern > len_title_extern) + pPreviousEvent->SetDescription(buffer_title_intern); + } + } + + if(pPreviousEvent->Vps() == 0 && pEvent->Vps() != 0) + pPreviousEvent->SetVps(pEvent->Vps()); + + pSchedule->DeleteEvent(pEvent); + pPreviousEvent->FixEpgBugs(); + } + else + pSchedule->DeleteEvent(pPreviousEvent); + } + } } if (Empty && Tid == 0x4E && getSectionNumber() == 0) // ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running diff -Nur vdr-1.3.18.org/epg.c vdr-1.3.18/epg.c --- vdr-1.3.18.org/epg.c 2005-01-02 12:25:26.000000000 +0100 +++ vdr-1.3.18/epg.c 2005-01-15 10:26:32.000000000 +0100 @@ -705,6 +705,35 @@ return pe; } +// deletes an given event :EW +void cSchedule::DeleteEvent(cEvent *Event) +{ + events.Del(Event); +} + +const cEvent *cSchedule::GetPreviousEvent(cEvent *Event) const +{ + + if(!Event || Event->Duration() == 0 || Event->StartTime() == 0) + return NULL; + // Returns either the event info to the previous/following event to the given EventID or, if that one can't be found NULL :EW + cEvent *pt = NULL; + int epgTimeDelta = Setup.DoubleEpgTimeDelta * 60 + 1; + for (pt = events.First(); pt; pt = events.Next(pt)) + if(pt && pt->TableID() == 0x00) + if ((Event->StartTime() - pt->StartTime()) > - epgTimeDelta && (Event->StartTime() - pt->StartTime()) < epgTimeDelta) + { + if((pt->Duration() + (pt->Duration()/ 5) + 1) > Event->Duration() && (pt->Duration() - (pt->Duration()/ 5) - 1) < Event->Duration()) + return pt; + else if (pt->Title() && Event->Title() && (strcmp(pt->Title(), ".") != 0 && strcmp(Event->Title(), ".") != 0)) + { + if (strstr(pt->Title(), Event->Title()) != NULL || strstr(Event->Title(), pt->Title()) != NULL) + return pt; + } + } + return NULL; +} + void cSchedule::SetRunningStatus(cEvent *Event, int RunningStatus, cChannel *Channel) { for (cEvent *p = events.First(); p; p = events.Next(p)) { diff -Nur vdr-1.3.18.org/epg.h vdr-1.3.18/epg.h --- vdr-1.3.18.org/epg.h 2005-01-02 11:44:42.000000000 +0100 +++ vdr-1.3.18/epg.h 2005-01-15 10:26:32.000000000 +0100 @@ -122,6 +122,8 @@ void Cleanup(time_t Time); void Cleanup(void); cEvent *AddEvent(cEvent *Event); + void DeleteEvent(cEvent *Event); //:EW + const cEvent *GetPreviousEvent(cEvent *Event) const; //:EW const cList *Events(void) const { return &events; } const cEvent *GetPresentEvent(bool CheckRunningStatus = false) const; const cEvent *GetFollowingEvent(bool CheckRunningStatus = false) const; diff -Nur vdr-1.3.18.org/i18n.c vdr-1.3.18/i18n.c --- vdr-1.3.18.org/i18n.c 2005-01-09 13:17:44.000000000 +0100 +++ vdr-1.3.18/i18n.c 2005-01-15 10:26:32.000000000 +0100 @@ -3787,6 +3787,74 @@ "Kanalivahetuse ooteaeg (s)", "Zap timeout (s)", }, + { "Setup.EPG$Period for double EPG search(min)", + "Zeitspanne für dop. EPG-Suche(min)", + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + }, + { "Setup.EPG$extern double Epg entry", + "Doppelten externen EPG-Eintrag", + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + }, + { "Setup.EPG$Mix intern and extern EPG", + "Internen und externen EPG mischen", + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + }, + { "Setup.EPG$Disable running VPS event", + "Erk. des lauf. VPS-Events abschalten", + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + "",// TODO + }, // The days of the week: { "MTWTFSS", "MDMDFSS", diff -Nur vdr-1.3.18.org/menu.c vdr-1.3.18/menu.c --- vdr-1.3.18.org/menu.c 2005-01-09 14:04:50.000000000 +0100 +++ vdr-1.3.18/menu.c 2005-01-15 10:26:32.000000000 +0100 @@ -1855,6 +1855,10 @@ Add(new cMenuEditIntItem( tr("Setup.EPG$Preferred languages"), &numLanguages, 0, I18nNumLanguages)); for (int i = 0; i < numLanguages; i++) Add(new cMenuEditStraItem(tr("Setup.EPG$Preferred language"), &data.EPGLanguages[i], I18nNumLanguages, I18nLanguages())); + Add(new cMenuEditIntItem(tr("Setup.EPG$Period for double EPG search(min)"), &data.DoubleEpgTimeDelta)); + Add(new cMenuEditBoolItem(tr("Setup.EPG$extern double Epg entry"), &data.DoubleEpgAction, "adjust", "delete")); + Add(new cMenuEditBoolItem(tr("Setup.EPG$Mix intern and extern EPG"), &data.MixEpgAction)); + Add(new cMenuEditBoolItem(tr("Setup.EPG$Disable running VPS event"), &data.DisableVPS)); SetCurrent(Get(current)); Display();