/** * Parse a <channel> tag from xmltv */ static int _xmltv_parse_channel (epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats) { int save =0; htsmsg_t *attribs, *tags, *subtag; const char *id, *name, *icon; epggrab_channel_t *ch; if(body == NULL) return 0; if((attribs = htsmsg_get_map(body, "attrib")) == NULL) return 0; if((id = htsmsg_get_str(attribs, "id")) == NULL) return 0; if((tags = htsmsg_get_map(body, "tags")) == NULL) return 0; if((ch = _xmltv_channel_find(id, 1, &save)) == NULL) return 0; stats->channels.total++; if (save) stats->channels.created++; if((name = htsmsg_xml_get_cdata_str(tags, "display-name")) != NULL) { save |= epggrab_channel_set_name(ch, name); } if((subtag = htsmsg_get_map(tags, "icon")) != NULL && (attribs = htsmsg_get_map(subtag, "attrib")) != NULL && (icon = htsmsg_get_str(attribs, "src")) != NULL) { save |= epggrab_channel_set_icon(ch, icon); } if (save) { epggrab_channel_updated(ch); stats->channels.modified++; } return save; }
static int _pyepg_parse_channel ( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats ) { int save = 0; epggrab_channel_t *ch; htsmsg_t *attr, *tags; const char *str; uint32_t u32; if ( data == NULL ) return 0; if ((attr = htsmsg_get_map(data, "attrib")) == NULL) return 0; if ((str = htsmsg_get_str(attr, "id")) == NULL) return 0; if ((tags = htsmsg_get_map(data, "tags")) == NULL) return 0; if (!(ch = _pyepg_channel_find(str, 1, &save))) return 0; stats->channels.total++; if (save) stats->channels.created++; /* Update data */ if ((str = htsmsg_xml_get_cdata_str(tags, "name"))) save |= epggrab_channel_set_name(ch, str); if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) save |= epggrab_channel_set_icon(ch, str); if ((!htsmsg_xml_get_cdata_u32(tags, "number", &u32))) save |= epggrab_channel_set_number(ch, u32, 0); /* Update */ if (save) { epggrab_channel_updated(ch); stats->channels.modified++; } return save; }