Update EIT and XMLTV processing to pick up and store new fields.
This commit is contained in:
parent
4365a25e7c
commit
e81e4f4fa1
2 changed files with 71 additions and 15 deletions
|
@ -115,6 +115,8 @@ typedef struct eit_event
|
|||
uint8_t ad, st, ds;
|
||||
uint8_t bw;
|
||||
|
||||
uint8_t parental;
|
||||
|
||||
} eit_event_t;
|
||||
|
||||
/* ************************************************************************
|
||||
|
@ -361,7 +363,27 @@ static int _eit_desc_content
|
|||
}
|
||||
|
||||
/*
|
||||
* Content ID
|
||||
* Parental rating Descriptor - 0x55
|
||||
*/
|
||||
static int _eit_desc_parental
|
||||
( epggrab_module_t *mod, uint8_t *ptr, int len, eit_event_t *ev )
|
||||
{
|
||||
int cnt = 0, sum = 0;
|
||||
while (len > 3) {
|
||||
if ( ptr[3] && ptr[3] < 0x10 ) {
|
||||
cnt++;
|
||||
sum += (ptr[3] + 3);
|
||||
}
|
||||
}
|
||||
// Note: we ignore the country code and average the lot!
|
||||
if (cnt)
|
||||
ev->parental = (uint8_t)(sum / cnt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Content ID - 0x76
|
||||
*/
|
||||
static int _eit_desc_crid
|
||||
( epggrab_module_t *mod, uint8_t *ptr, int len, eit_event_t *ev, service_t *svc )
|
||||
|
@ -489,11 +511,9 @@ static int _eit_process_event
|
|||
case DVB_DESC_COMPONENT:
|
||||
r = _eit_desc_component(mod, ptr, dlen, &ev);
|
||||
break;
|
||||
#if TODO_AGE_RATING
|
||||
case DVB_DESC_PARENTAL_RAT:
|
||||
r = _eit_desc_parental(mod, ptr, dlen, &ev);
|
||||
break;
|
||||
#endif
|
||||
case DVB_DESC_CRID:
|
||||
r = _eit_desc_crid(mod, ptr, dlen, &ev, svc);
|
||||
break;
|
||||
|
@ -554,6 +574,8 @@ static int _eit_process_event
|
|||
*save |= epg_episode_set_title2(ee, ev.title, mod);
|
||||
if ( ev.genre )
|
||||
*save |= epg_episode_set_genre(ee, ev.genre, mod);
|
||||
if ( ev.parental )
|
||||
*save |= epg_episode_set_age_rating(ee, ev.parental, mod);
|
||||
#if TODO_ADD_EXTRA
|
||||
if ( ev.extra )
|
||||
*save |= epg_episode_set_extra(ee, extra, mod);
|
||||
|
|
|
@ -239,9 +239,8 @@ static void get_episode_info
|
|||
* job
|
||||
*/
|
||||
static int
|
||||
parse_vid_quality
|
||||
( epggrab_module_t *mod, epg_broadcast_t *ebc, epg_episode_t *ee,
|
||||
htsmsg_t *m )
|
||||
xmltv_parse_vid_quality
|
||||
( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *m, uint8_t *bw )
|
||||
{
|
||||
int save = 0;
|
||||
int hd = 0, lines = 0, aspect = 0;
|
||||
|
@ -249,7 +248,7 @@ parse_vid_quality
|
|||
if (!ebc || !m) return 0;
|
||||
|
||||
if ((str = htsmsg_xml_get_cdata_str(m, "colour")))
|
||||
save |= epg_episode_set_is_bw(ee, strcmp(str, "no") ? 0 : 1, mod);
|
||||
*bw = strcmp(str, "no") ? 0 : 1;
|
||||
if ((str = htsmsg_xml_get_cdata_str(m, "quality"))) {
|
||||
if (strstr(str, "HD")) {
|
||||
hd = 1;
|
||||
|
@ -314,6 +313,36 @@ xmltv_parse_accessibility
|
|||
return save;
|
||||
}
|
||||
|
||||
/*
|
||||
* Previously shown
|
||||
*/
|
||||
static int _xmltv_parse_previously_shown
|
||||
( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *tag,
|
||||
time_t *first_aired )
|
||||
{
|
||||
int ret;
|
||||
const char *start;
|
||||
if (!mod || !ebc || !tag) return 0;
|
||||
ret = epg_broadcast_set_is_repeat(ebc, 1, mod);
|
||||
if ((start = htsmsg_xml_get_attr_str(tag, "start")))
|
||||
*first_aired = _xmltv_str2time(start);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Star rating
|
||||
*/
|
||||
static int _xmltv_parse_star_rating
|
||||
( epggrab_module_t *mod, epg_episode_t *ee, htsmsg_t *tags )
|
||||
{
|
||||
int a, b;
|
||||
const char *stars;
|
||||
if (!mod || !ee || !tags) return 0;
|
||||
if (!(stars = htsmsg_xml_get_cdata_str(tags, "star-rating"))) return 0;
|
||||
if (sscanf(stars, "%d/%d", &a, &b) != 2) return 0;
|
||||
return epg_episode_set_star_rating(ee, (5 * a) / b, mod);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse category list
|
||||
*/
|
||||
|
@ -371,6 +400,8 @@ static int _xmltv_parse_programme_tags
|
|||
lang_str_t *title = NULL;
|
||||
lang_str_t *desc = NULL;
|
||||
lang_str_t *subtitle = NULL;
|
||||
time_t first_aired = 0;
|
||||
uint8_t bw = -1;
|
||||
|
||||
/*
|
||||
* Broadcast
|
||||
|
@ -386,16 +417,15 @@ static int _xmltv_parse_programme_tags
|
|||
save3 |= epg_broadcast_set_description2(ebc, desc, mod);
|
||||
|
||||
/* Quality metadata */
|
||||
save |= parse_vid_quality(mod, ebc, ee, htsmsg_get_map(tags, "video"));
|
||||
save |= xmltv_parse_vid_quality(mod, ebc, htsmsg_get_map(tags, "video"), &bw);
|
||||
|
||||
/* Accessibility */
|
||||
save |= xmltv_parse_accessibility(mod, ebc, tags);
|
||||
|
||||
/* Misc */
|
||||
if (htsmsg_get_map(tags, "previously-shown"))
|
||||
save |= epg_broadcast_set_is_repeat(ebc, 1, mod);
|
||||
else if (htsmsg_get_map(tags, "premiere") ||
|
||||
htsmsg_get_map(tags, "new"))
|
||||
save |= _xmltv_parse_previously_shown(mod, ebc, tags, &first_aired);
|
||||
if (htsmsg_get_map(tags, "premiere") ||
|
||||
htsmsg_get_map(tags, "new"))
|
||||
save |= epg_broadcast_set_is_new(ebc, 1, mod);
|
||||
|
||||
/*
|
||||
|
@ -443,11 +473,15 @@ static int _xmltv_parse_programme_tags
|
|||
epg_genre_list_destroy(egl);
|
||||
}
|
||||
|
||||
if (bw != -1)
|
||||
save3 |= epg_episode_set_is_bw(ee, bw, mod);
|
||||
|
||||
save3 |= epg_episode_set_epnum(ee, &epnum, mod);
|
||||
|
||||
// TODO: need to handle certification and ratings
|
||||
// TODO: need to handle season numbering!
|
||||
// TODO: need to handle onscreen numbering
|
||||
save3 |= _xmltv_parse_star_rating(mod, ee, tags);
|
||||
|
||||
|
||||
// TODO: parental rating
|
||||
}
|
||||
|
||||
/* Stats */
|
||||
|
|
Loading…
Add table
Reference in a new issue