static int _pyepg_parse_broadcast ( epggrab_module_t *mod, htsmsg_t *data, channel_t *channel, epggrab_stats_t *stats ) { int save = 0; htsmsg_t *attr, *tags; epg_episode_t *episode; epg_broadcast_t *broadcast; const char *id, *start, *stop; time_t tm_start, tm_stop; uint32_t u32; if ( data == NULL || channel == NULL ) return 0; if ((attr = htsmsg_get_map(data, "attrib")) == NULL) return 0; if ((id = htsmsg_get_str(attr, "episode")) == NULL) return 0; if ((start = htsmsg_get_str(attr, "start")) == NULL ) return 0; if ((stop = htsmsg_get_str(attr, "stop")) == NULL ) return 0; if ((tags = htsmsg_get_map(data, "tags")) == NULL) return 0; /* Parse times */ if (!_pyepg_parse_time(start, &tm_start)) return 0; if (!_pyepg_parse_time(stop, &tm_stop)) return 0; /* Find broadcast */ broadcast = epg_broadcast_find_by_time(channel, tm_start, tm_stop, 0, 1, &save); if ( broadcast == NULL ) return 0; stats->broadcasts.total++; if ( save ) stats->broadcasts.created++; /* Quality */ u32 = htsmsg_get_map(tags, "hd") ? 1 : 0; save |= epg_broadcast_set_is_hd(broadcast, u32, mod); u32 = htsmsg_get_map(tags, "widescreen") ? 1 : 0; save |= epg_broadcast_set_is_widescreen(broadcast, u32, mod); // TODO: lines, aspect /* Accessibility */ // Note: reuse XMLTV parse code as this is the same xmltv_parse_accessibility(mod, broadcast, tags); /* New/Repeat */ u32 = htsmsg_get_map(tags, "new") || htsmsg_get_map(tags, "premiere"); save |= epg_broadcast_set_is_new(broadcast, u32, mod); u32 = htsmsg_get_map(tags, "repeat") ? 1 : 0; save |= epg_broadcast_set_is_repeat(broadcast, u32, mod); /* Set episode */ if ((episode = epg_episode_find_by_uri(id, 1, &save)) == NULL) return 0; save |= epg_broadcast_set_episode(broadcast, episode, mod); if (save) stats->broadcasts.modified++; return save; }
/* * Process video quality flags * * Note: this is very rough/approx someone might be able to do a much better * job */ static int xmltv_parse_vid_quality ( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *m, int8_t *bw ) { int save = 0; int hd = 0, lines = 0, aspect = 0; const char *str; if (!ebc || !m) return 0; if ((str = htsmsg_xml_get_cdata_str(m, "colour"))) *bw = strcmp(str, "no") ? 0 : 1; if ((str = htsmsg_xml_get_cdata_str(m, "quality"))) { if (strstr(str, "HD")) { hd = 1; } else if (strstr(str, "480")) { lines = 480; aspect = 150; } else if (strstr(str, "576")) { lines = 576; aspect = 133; } else if (strstr(str, "720")) { lines = 720; hd = 1; aspect = 178; } else if (strstr(str, "1080")) { lines = 1080; hd = 1; aspect = 178; } } if ((str = htsmsg_xml_get_cdata_str(m, "aspect"))) { int w, h; if (sscanf(str, "%d:%d", &w, &h) == 2) { aspect = (100 * w) / h; } } save |= epg_broadcast_set_is_hd(ebc, hd, mod); if (aspect) { save |= epg_broadcast_set_is_widescreen(ebc, hd || aspect > 137, mod); save |= epg_broadcast_set_aspect(ebc, aspect, mod); } if (lines) save |= epg_broadcast_set_lines(ebc, lines, mod); return save; }