From: Jaroslav Kysela Date: Sat, 19 Nov 2016 17:36:02 +0000 (+0100) Subject: epg: try to handle the broken EPG input - add stop cut function, fixes #4076 X-Git-Tag: v4.2.1~215 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a113b607d2a463df1b7091bfaeada5616739e97;p=thirdparty%2Ftvheadend.git epg: try to handle the broken EPG input - add stop cut function, fixes #4076 --- diff --git a/src/config.c b/src/config.c index 340e97e64..1cee017c7 100644 --- a/src/config.c +++ b/src/config.c @@ -1638,6 +1638,7 @@ config_boot ( const char *path, gid_t gid, uid_t uid ) config.dscp = -1; config.descrambler_buffer = 9000; config.epg_compress = 1; + config.epg_cutwindow = 5*60; config_scanfile_ok = 0; config.theme_ui = strdup("blue"); @@ -2180,9 +2181,18 @@ const idclass_t config_class = { .off = offsetof(config_t, epg_compress), .opts = PO_EXPERT, .def.i = 1, - .group = 1 + .group = 2 }, #endif + { + .type = PT_U32, + .id = "epg_cutwindow", + .name = N_("EPG overlap cut"), + .desc = N_("The time window to cut the stop time from the overlapped event in seconds."), + .off = offsetof(config_t, epg_cutwindow), + .opts = PO_EXPERT, + .group = 2 + }, { .type = PT_STR, .islist = 1, diff --git a/src/config.h b/src/config.h index 2e135f353..a2a7f648e 100644 --- a/src/config.h +++ b/src/config.h @@ -58,6 +58,7 @@ typedef struct config { int caclient_ui; int parser_backlog; int epg_compress; + uint32_t epg_cutwindow; } config_t; extern const idclass_t config_class; diff --git a/src/epg.c b/src/epg.c index 8277e9c28..51046f0ed 100644 --- a/src/epg.c +++ b/src/epg.c @@ -26,6 +26,7 @@ #include #include "tvheadend.h" +#include "config.h" #include "queue.h" #include "channels.h" #include "settings.h" @@ -1695,6 +1696,17 @@ static epg_broadcast_t *_epg_channel_add_broadcast _epg_channel_rem_broadcast(ch, ret, NULL); return NULL; } + if (config.epg_cutwindow && ebc->stop - ebc->start > config.epg_cutwindow * 2 && + ebc->stop - ret->start <= config.epg_cutwindow) { + tvhtrace(LS_EPG, "cut stop for overlap (b) event %u (%s) on %s @ %s to %s", + ebc->id, epg_broadcast_get_title(ebc, NULL), + channel_get_name(ch), + gmtime2local(ebc->start, tm1, sizeof(tm1)), + gmtime2local(ebc->stop, tm2, sizeof(tm2))); + ebc->stop = ret->start; + _epg_object_set_updated(ebc); + continue; + } tvhtrace(LS_EPG, "remove overlap (b) event %u (%s) on %s @ %s to %s", ebc->id, epg_broadcast_get_title(ebc, NULL), channel_get_name(ch), @@ -1711,6 +1723,17 @@ static epg_broadcast_t *_epg_channel_add_broadcast _epg_channel_rem_broadcast(ch, ret, NULL); return NULL; } + if (config.epg_cutwindow && ret->stop - ret->start > config.epg_cutwindow * 2 && + ret->stop - ebc->start <= config.epg_cutwindow) { + tvhtrace(LS_EPG, "cut stop for overlap (a) event %u (%s) on %s @ %s to %s", + ebc->id, epg_broadcast_get_title(ebc, NULL), + channel_get_name(ch), + gmtime2local(ebc->start, tm1, sizeof(tm1)), + gmtime2local(ebc->stop, tm2, sizeof(tm2))); + ret->stop = ebc->start; + _epg_object_set_updated(ebc); + continue; + } tvhtrace(LS_EPG, "remove overlap (a) event %u (%s) on %s @ %s to %s", ebc->id, epg_broadcast_get_title(ebc, NULL), channel_get_name(ch),