diff --git a/src/epg.c b/src/epg.c index ca72334b..fce65a53 100644 --- a/src/epg.c +++ b/src/epg.c @@ -1107,14 +1107,19 @@ static epg_broadcast_t *_epg_channel_add_broadcast // Note: sets updated _epg_object_getref(ret); - /* No change */ - } else if ( ret->stop == (*bcast)->stop ) { - return ret; - - /* Extend in time */ + /* Existing */ } else { - ret->stop = (*bcast)->stop; - _epg_object_set_updated(ret); + *save |= _epg_object_set_u16(ret, &ret->dvb_eid, (*bcast)->dvb_eid, NULL); + + /* No time change */ + if ( ret->stop == (*bcast)->stop ) { + return ret; + + /* Extend in time */ + } else { + ret->stop = (*bcast)->stop; + _epg_object_set_updated(ret); + } } } @@ -1198,6 +1203,7 @@ epg_broadcast_t* epg_broadcast_find_by_time ebc = _epg_broadcast_skel(); (*ebc)->start = start; (*ebc)->stop = stop; + (*ebc)->dvb_eid = eid; return _epg_channel_add_broadcast(channel, ebc, create, save); } @@ -1209,7 +1215,7 @@ epg_broadcast_t *epg_broadcast_find_by_id ( uint64_t id, channel_t *ch ) return (epg_broadcast_t*)_epg_object_find_by_id(id, EPG_BROADCAST); } -epg_broadcast_t *epg_broadcast_find_by_eid ( channel_t *ch, int eid ) +epg_broadcast_t *epg_broadcast_find_by_eid ( channel_t *ch, uint16_t eid ) { epg_broadcast_t *e; RB_FOREACH(e, &ch->ch_epg_schedule, sched_link) { diff --git a/src/epg.h b/src/epg.h index 07357184..97dcd7a7 100644 --- a/src/epg.h +++ b/src/epg.h @@ -343,7 +343,7 @@ struct epg_broadcast { epg_object_t; ///< Parent object - int dvb_eid; ///< DVB Event ID + uint16_t dvb_eid; ///< DVB Event ID time_t start; ///< Start time time_t stop; ///< End time @@ -373,7 +373,7 @@ struct epg_broadcast epg_broadcast_t *epg_broadcast_find_by_time ( struct channel *ch, time_t start, time_t stop, uint16_t eid, int create, int *save ); -epg_broadcast_t *epg_broadcast_find_by_eid ( struct channel *ch, int eid ); +epg_broadcast_t *epg_broadcast_find_by_eid ( struct channel *ch, uint16_t eid ); epg_broadcast_t *epg_broadcast_find_by_id ( uint64_t id, struct channel *ch ); /* Mutators */ diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index ab03bc8f..f07782b1 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -378,7 +378,7 @@ static int _opentv_parse_event_section 1, &save); /* Store */ - } else { + } else if (!(ebc = epg_broadcast_find_by_eid(ec->channel, ev.eid))) { opentv_event_t *skel = malloc(sizeof(opentv_event_t)); memcpy(skel, &ev, sizeof(opentv_event_t)); assert(!RB_INSERT_SORTED(&sta->events, skel, ev_link, _ev_cmp));