]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
opentv: fix incorrect summaries for skyuk epg, fixes #5995
authorJames Hutchinson <jahutchinson99@googlemail.com>
Sun, 26 Sep 2021 18:30:40 +0000 (19:30 +0100)
committerFlole998 <Flole998@users.noreply.github.com>
Sun, 17 Oct 2021 00:12:53 +0000 (02:12 +0200)
Events within the OpenTV SkyUK data can contain the same Event ID as
another event on a different channel.

This resulted in missing or incorrect summary data, since matching was
based solely on the Event ID.

This commit adjusts the opentv _entry_cmp function to match based on a
combination of Event ID and Channel ID. This enables the RB_FIND &
RB_INSERT_SORTED functions used within the OpenTV module to reliably
insert and uniquely find the correct entry.

src/epggrab/module/opentv.c

index fa73927c6ea09051a750a6230da0002eba622575..308e49d8cd250a592374314482960a697139b6b0 100644 (file)
@@ -140,6 +140,7 @@ typedef struct opentv_event
   char                  *desc;        ///< Event description
   uint8_t                cat;         ///< Event category
   uint16_t               serieslink;  ///< Series link ID
+  int                    cid;         ///< Channel ID
 } opentv_event_t;
 
 /* Queued (unresolved) event entry */
@@ -202,20 +203,28 @@ static void _opentv_event_free(opentv_event_t *ev)
   free(ev->desc);
 }
 
-/* Compare event id codes */
+/* Compare event id and channel id codes */
 static int _entry_cmp ( void *a, void *b )
 {
-  return (int)(((opentv_entry_t*)a)->event.eid) -
-         (int)(((opentv_entry_t*)b)->event.eid);
+  int eid_cmp, cid_cmp;
+
+  eid_cmp = (int)(((opentv_entry_t*)a)->event.eid) -
+            (int)(((opentv_entry_t*)b)->event.eid);
+
+  cid_cmp = ((opentv_entry_t*)a)->event.cid -
+            ((opentv_entry_t*)b)->event.cid;
+
+  return eid_cmp != 0 ? eid_cmp : cid_cmp;
 }
 
 /* Find event entry */
-static opentv_entry_t *opentv_find_entry(opentv_status_t *sta, uint16_t eid)
+static opentv_entry_t *opentv_find_entry(opentv_status_t *sta, uint16_t eid, int cid)
 {
   opentv_entry_t *oe, _tmp;
 
   if (sta == NULL) return NULL;
   _tmp.event.eid = eid;
+  _tmp.event.cid = cid;
   oe = RB_FIND(&sta->os_entries, &_tmp, link, _entry_cmp);
   return oe;
 }
@@ -341,6 +350,7 @@ static int _opentv_parse_event
   }
 
   ev->eid = ((uint16_t)buf[0] << 8) | buf[1];
+  ev->cid = cid;
 
   /* Process records */ 
   while (i < slen+4) {
@@ -503,7 +513,7 @@ opentv_parse_event_section_one
     if (ebc) {
       save |= opentv_do_event(mod, ebc, &ev, ch, lang, &changes);
       if (!merge) {
-        entry = opentv_find_entry(mod->sta, ev.eid);
+        entry = opentv_find_entry(mod->sta, ev.eid, cid);
         if (entry) {
           save |= opentv_do_event(mod, ebc, &entry->event, ch, lang, &changes);
           opentv_remove_entry(mod->sta, entry);