Updated grabber modules to new EPG api.

This commit is contained in:
Adam Sutton 2012-07-11 10:43:14 +01:00
parent cff7beea59
commit b9c34db3d1
5 changed files with 126 additions and 104 deletions

View file

@ -145,7 +145,7 @@ static int _eit_callback
( th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len, ( th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
uint8_t tableid, void *opaque ) uint8_t tableid, void *opaque )
{ {
epggrab_module_ota_t *mod = opaque; epggrab_module_t *mod = opaque;
epggrab_ota_mux_t *ota; epggrab_ota_mux_t *ota;
th_dvb_adapter_t *tda; th_dvb_adapter_t *tda;
service_t *svc; service_t *svc;
@ -168,7 +168,7 @@ static int _eit_callback
return -1; return -1;
/* Get OTA */ /* Get OTA */
ota = epggrab_ota_find(mod, tdmi); ota = epggrab_ota_find((epggrab_module_ota_t*)mod, tdmi);
if (!ota || !ota->status) return 0; if (!ota || !ota->status) return 0;
sta = ota->status; sta = ota->status;
@ -363,11 +363,11 @@ static int _eit_callback
/* Metadata */ /* Metadata */
if ( save2 ) { if ( save2 ) {
save |= epg_broadcast_set_is_hd(ebc, hd); save |= epg_broadcast_set_is_hd(ebc, hd, mod);
save |= epg_broadcast_set_is_widescreen(ebc, ws); save |= epg_broadcast_set_is_widescreen(ebc, ws, mod);
save |= epg_broadcast_set_is_audio_desc(ebc, ad); save |= epg_broadcast_set_is_audio_desc(ebc, ad, mod);
save |= epg_broadcast_set_is_subtitled(ebc, st); save |= epg_broadcast_set_is_subtitled(ebc, st, mod);
save |= epg_broadcast_set_is_deafsigned(ebc, ds); save |= epg_broadcast_set_is_deafsigned(ebc, ds, mod);
} }
/* Create episode */ /* Create episode */
@ -377,7 +377,7 @@ static int _eit_callback
uri = epg_hash(title, summary, desc); uri = epg_hash(title, summary, desc);
if (uri) { if (uri) {
if ((ee = epg_episode_find_by_uri(uri, 1, &save2))) if ((ee = epg_episode_find_by_uri(uri, 1, &save2)))
save |= epg_broadcast_set_episode(ebc, ee); save |= epg_broadcast_set_episode(ebc, ee, mod);
free(uri); free(uri);
} }
} }
@ -385,18 +385,18 @@ static int _eit_callback
/* Episode data */ /* Episode data */
if (ee) { if (ee) {
save |= epg_episode_set_is_bw(ee, bw); save |= epg_episode_set_is_bw(ee, bw, mod);
if ( !ee->title && *title ) if ( *title )
save |= epg_episode_set_title(ee, title); save |= epg_episode_set_title(ee, title, mod);
if ( !ee->summary && *summary ) if ( *summary )
save |= epg_episode_set_summary(ee, summary); save |= epg_episode_set_summary(ee, summary, mod);
if ( !ee->description && *desc ) if ( *desc )
save |= epg_episode_set_description(ee, desc); save |= epg_episode_set_description(ee, desc, mod);
if ( !LIST_FIRST(&ee->genre) && egl ) if ( egl )
save |= epg_episode_set_genre(ee, egl); save |= epg_episode_set_genre(ee, egl, mod);
#if TODO_ADD_EXTRA #if TODO_ADD_EXTRA
if ( extra ) if ( extra )
save |= epg_episode_set_extra(ee, extra); save |= epg_episode_set_extra(ee, extra, mod);
#endif #endif
} }

View file

@ -349,6 +349,7 @@ static int _opentv_parse_event_section
epg_episode_t *ee; epg_episode_t *ee;
epg_season_t *es; epg_season_t *es;
opentv_event_t ev; opentv_event_t ev;
epggrab_module_t *src = (epggrab_module_t*)mod;
/* Channel */ /* Channel */
cid = ((int)buf[0] << 8) | buf[1]; cid = ((int)buf[0] << 8) | buf[1];
@ -398,27 +399,27 @@ static int _opentv_parse_event_section
/* Update */ /* Update */
if (ee) { if (ee) {
if (!ev.title && ebc->episode) if (!ev.title && ebc->episode)
save |= epg_episode_set_title(ee, ebc->episode->title); save |= epg_episode_set_title(ee, ebc->episode->title, src);
else if (ev.title) else if (ev.title)
save |= epg_episode_set_title(ee, ev.title); save |= epg_episode_set_title(ee, ev.title, src);
if (ev.summary) if (ev.summary)
save |= epg_episode_set_summary(ee, ev.summary); save |= epg_episode_set_summary(ee, ev.summary, src);
if (ev.desc) if (ev.desc)
save |= epg_episode_set_description(ee, ev.desc); save |= epg_episode_set_description(ee, ev.desc, src);
if (ev.cat) { if (ev.cat) {
epg_genre_list_t *egl = calloc(1, sizeof(epg_genre_list_t)); epg_genre_list_t *egl = calloc(1, sizeof(epg_genre_list_t));
epg_genre_list_add_by_eit(egl, ev.cat); epg_genre_list_add_by_eit(egl, ev.cat);
save |= epg_episode_set_genre(ee, egl); save |= epg_episode_set_genre(ee, egl, src);
epg_genre_list_destroy(egl); epg_genre_list_destroy(egl);
} }
// Note: don't override the season (since the ID is channel specific // Note: don't override the season (since the ID is channel specific
// it'll keep changing! // it'll keep changing!
if (ev.series && !ee->season) { if (ev.series && !ee->season) {
es = _opentv_find_season(mod, cid, ev.series); es = _opentv_find_season(mod, cid, ev.series);
if (es) save |= epg_episode_set_season(ee, es); if (es) save |= epg_episode_set_season(ee, es, src);
} }
save |= epg_broadcast_set_episode(ebc, ee); save |= epg_broadcast_set_episode(ebc, ee, src);
} }
} }

View file

@ -71,7 +71,8 @@ static epg_genre_list_t
return egl; return egl;
} }
static int _pyepg_parse_channel ( htsmsg_t *data, epggrab_stats_t *stats ) static int _pyepg_parse_channel
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
epggrab_channel_t *ch; epggrab_channel_t *ch;
@ -105,7 +106,8 @@ static int _pyepg_parse_channel ( htsmsg_t *data, epggrab_stats_t *stats )
return save; return save;
} }
static int _pyepg_parse_brand ( htsmsg_t *data, epggrab_stats_t *stats ) static int _pyepg_parse_brand
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
htsmsg_t *attr, *tags; htsmsg_t *attr, *tags;
@ -126,24 +128,24 @@ static int _pyepg_parse_brand ( htsmsg_t *data, epggrab_stats_t *stats )
/* Set title */ /* Set title */
if ((str = htsmsg_xml_get_cdata_str(tags, "title"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "title"))) {
save |= epg_brand_set_title(brand, str); save |= epg_brand_set_title(brand, str, mod);
} }
/* Set summary */ /* Set summary */
if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) {
save |= epg_brand_set_summary(brand, str); save |= epg_brand_set_summary(brand, str, mod);
} }
/* Set image */ /* Set image */
if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) {
save |= epg_brand_set_image(brand, str); save |= epg_brand_set_image(brand, str, mod);
} else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) { } else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) {
save |= epg_brand_set_image(brand, str); save |= epg_brand_set_image(brand, str, mod);
} }
/* Set season count */ /* Set season count */
if (htsmsg_xml_get_cdata_u32(tags, "series-count", &u32) == 0) { if (htsmsg_xml_get_cdata_u32(tags, "series-count", &u32) == 0) {
save |= epg_brand_set_season_count(brand, u32); save |= epg_brand_set_season_count(brand, u32, mod);
} }
if (save) stats->brands.modified++; if (save) stats->brands.modified++;
@ -151,7 +153,8 @@ static int _pyepg_parse_brand ( htsmsg_t *data, epggrab_stats_t *stats )
return save; return save;
} }
static int _pyepg_parse_season ( htsmsg_t *data, epggrab_stats_t *stats ) static int _pyepg_parse_season
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
htsmsg_t *attr, *tags; htsmsg_t *attr, *tags;
@ -174,30 +177,30 @@ static int _pyepg_parse_season ( htsmsg_t *data, epggrab_stats_t *stats )
/* Set brand */ /* Set brand */
if ((str = htsmsg_get_str(attr, "brand"))) { if ((str = htsmsg_get_str(attr, "brand"))) {
if ((brand = epg_brand_find_by_uri(str, 0, NULL))) { if ((brand = epg_brand_find_by_uri(str, 0, NULL))) {
save |= epg_season_set_brand(season, brand, 1); save |= epg_season_set_brand(season, brand, mod);
} }
} }
/* Set summary */ /* Set summary */
if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) {
save |= epg_season_set_summary(season, str); save |= epg_season_set_summary(season, str, mod);
} }
/* Set image */ /* Set image */
if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) {
save |= epg_season_set_image(season, str); save |= epg_season_set_image(season, str, mod);
} else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) { } else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) {
save |= epg_season_set_image(season, str); save |= epg_season_set_image(season, str, mod);
} }
/* Set season number */ /* Set season number */
if (htsmsg_xml_get_cdata_u32(tags, "number", &u32) == 0) { if (htsmsg_xml_get_cdata_u32(tags, "number", &u32) == 0) {
save |= epg_season_set_number(season, u32); save |= epg_season_set_number(season, u32, mod);
} }
/* Set episode count */ /* Set episode count */
if (htsmsg_xml_get_cdata_u32(tags, "episode-count", &u32) == 0) { if (htsmsg_xml_get_cdata_u32(tags, "episode-count", &u32) == 0) {
save |= epg_season_set_episode_count(season, u32); save |= epg_season_set_episode_count(season, u32, mod);
} }
if(save) stats->seasons.modified++; if(save) stats->seasons.modified++;
@ -205,7 +208,8 @@ static int _pyepg_parse_season ( htsmsg_t *data, epggrab_stats_t *stats )
return save; return save;
} }
static int _pyepg_parse_episode ( htsmsg_t *data, epggrab_stats_t *stats ) static int _pyepg_parse_episode
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
htsmsg_t *attr, *tags; htsmsg_t *attr, *tags;
@ -230,56 +234,56 @@ static int _pyepg_parse_episode ( htsmsg_t *data, epggrab_stats_t *stats )
/* Set season */ /* Set season */
if ((str = htsmsg_get_str(attr, "series"))) { if ((str = htsmsg_get_str(attr, "series"))) {
if ((season = epg_season_find_by_uri(str, 0, NULL))) { if ((season = epg_season_find_by_uri(str, 0, NULL))) {
save |= epg_episode_set_season(episode, season); save |= epg_episode_set_season(episode, season, mod);
} }
} }
/* Set brand */ /* Set brand */
if ((str = htsmsg_get_str(attr, "brand"))) { if ((str = htsmsg_get_str(attr, "brand"))) {
if ((brand = epg_brand_find_by_uri(str, 0, NULL))) { if ((brand = epg_brand_find_by_uri(str, 0, NULL))) {
save |= epg_episode_set_brand(episode, brand); save |= epg_episode_set_brand(episode, brand, mod);
} }
} }
/* Set title/subtitle */ /* Set title/subtitle */
if ((str = htsmsg_xml_get_cdata_str(tags, "title"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "title"))) {
save |= epg_episode_set_title(episode, str); save |= epg_episode_set_title(episode, str, mod);
} }
if ((str = htsmsg_xml_get_cdata_str(tags, "subtitle"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "subtitle"))) {
save |= epg_episode_set_subtitle(episode, str); save |= epg_episode_set_subtitle(episode, str, mod);
} }
/* Set summary */ /* Set summary */
if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "summary"))) {
save |= epg_episode_set_summary(episode, str); save |= epg_episode_set_summary(episode, str, mod);
} }
/* Number */ /* Number */
if (htsmsg_xml_get_cdata_u32(tags, "number", &u32) == 0) { if (htsmsg_xml_get_cdata_u32(tags, "number", &u32) == 0) {
save |= epg_episode_set_number(episode, u32); save |= epg_episode_set_number(episode, u32, mod);
} }
if (!htsmsg_xml_get_cdata_u32(tags, "part-number", &pn)) { if (!htsmsg_xml_get_cdata_u32(tags, "part-number", &pn)) {
pc = 0; pc = 0;
htsmsg_xml_get_cdata_u32(tags, "part-count", &pc); htsmsg_xml_get_cdata_u32(tags, "part-count", &pc);
save |= epg_episode_set_part(episode, pn, pc); save |= epg_episode_set_part(episode, pn, pc, mod);
} }
/* Set image */ /* Set image */
if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) { if ((str = htsmsg_xml_get_cdata_str(tags, "image"))) {
save |= epg_episode_set_image(episode, str); save |= epg_episode_set_image(episode, str, mod);
} else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) { } else if ((str = htsmsg_xml_get_cdata_str(tags, "thumb"))) {
save |= epg_episode_set_image(episode, str); save |= epg_episode_set_image(episode, str, mod);
} }
/* Genre */ /* Genre */
if ((egl = _pyepg_parse_genre(tags))) { if ((egl = _pyepg_parse_genre(tags))) {
save |= epg_episode_set_genre(episode, egl); save |= epg_episode_set_genre(episode, egl, mod);
epg_genre_list_destroy(egl); epg_genre_list_destroy(egl);
} }
/* Content */ /* Content */
if ((htsmsg_get_map(tags, "blackandwhite"))) if ((htsmsg_get_map(tags, "blackandwhite")))
save |= epg_episode_set_is_bw(episode, 1); save |= epg_episode_set_is_bw(episode, 1, mod);
if (save) stats->episodes.modified++; if (save) stats->episodes.modified++;
@ -287,7 +291,8 @@ static int _pyepg_parse_episode ( htsmsg_t *data, epggrab_stats_t *stats )
} }
static int _pyepg_parse_broadcast static int _pyepg_parse_broadcast
( htsmsg_t *data, channel_t *channel, epggrab_stats_t *stats ) ( epggrab_module_t *mod, htsmsg_t *data, channel_t *channel,
epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
htsmsg_t *attr, *tags; htsmsg_t *attr, *tags;
@ -320,31 +325,32 @@ static int _pyepg_parse_broadcast
if ( save ) stats->broadcasts.created++; if ( save ) stats->broadcasts.created++;
/* Set episode */ /* Set episode */
save |= epg_broadcast_set_episode(broadcast, episode); save |= epg_broadcast_set_episode(broadcast, episode, mod);
/* Quality */ /* Quality */
u32 = htsmsg_get_map(tags, "hd") ? 1 : 0; u32 = htsmsg_get_map(tags, "hd") ? 1 : 0;
save |= epg_broadcast_set_is_hd(broadcast, u32); save |= epg_broadcast_set_is_hd(broadcast, u32, mod);
u32 = htsmsg_get_map(tags, "widescreen") ? 1 : 0; u32 = htsmsg_get_map(tags, "widescreen") ? 1 : 0;
save |= epg_broadcast_set_is_widescreen(broadcast, u32); save |= epg_broadcast_set_is_widescreen(broadcast, u32, mod);
// TODO: lines, aspect // TODO: lines, aspect
/* Accessibility */ /* Accessibility */
// Note: reuse XMLTV parse code as this is the same // Note: reuse XMLTV parse code as this is the same
xmltv_parse_accessibility(broadcast, tags); xmltv_parse_accessibility(mod, broadcast, tags);
/* New/Repeat */ /* New/Repeat */
u32 = htsmsg_get_map(tags, "new") || htsmsg_get_map(tags, "premiere"); u32 = htsmsg_get_map(tags, "new") || htsmsg_get_map(tags, "premiere");
save |= epg_broadcast_set_is_new(broadcast, u32); save |= epg_broadcast_set_is_new(broadcast, u32, mod);
u32 = htsmsg_get_map(tags, "repeat") ? 1 : 0; u32 = htsmsg_get_map(tags, "repeat") ? 1 : 0;
save |= epg_broadcast_set_is_repeat(broadcast, u32); save |= epg_broadcast_set_is_repeat(broadcast, u32, mod);
if (save) stats->broadcasts.modified++; if (save) stats->broadcasts.modified++;
return save; return save;
} }
static int _pyepg_parse_schedule ( htsmsg_t *data, epggrab_stats_t *stats ) static int _pyepg_parse_schedule
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
htsmsg_t *attr, *tags; htsmsg_t *attr, *tags;
@ -362,7 +368,7 @@ static int _pyepg_parse_schedule ( htsmsg_t *data, epggrab_stats_t *stats )
HTSMSG_FOREACH(f, tags) { HTSMSG_FOREACH(f, tags) {
if (strcmp(f->hmf_name, "broadcast") == 0) { if (strcmp(f->hmf_name, "broadcast") == 0) {
save |= _pyepg_parse_broadcast(htsmsg_get_map_by_field(f), save |= _pyepg_parse_broadcast(mod, htsmsg_get_map_by_field(f),
ec->channel, stats); ec->channel, stats);
} }
} }
@ -370,7 +376,8 @@ static int _pyepg_parse_schedule ( htsmsg_t *data, epggrab_stats_t *stats )
return save; return save;
} }
static int _pyepg_parse_epg ( htsmsg_t *data, epggrab_stats_t *stats ) static int _pyepg_parse_epg
( epggrab_module_t *mod, htsmsg_t *data, epggrab_stats_t *stats )
{ {
int save = 0; int save = 0;
htsmsg_t *tags; htsmsg_t *tags;
@ -380,15 +387,15 @@ static int _pyepg_parse_epg ( htsmsg_t *data, epggrab_stats_t *stats )
HTSMSG_FOREACH(f, tags) { HTSMSG_FOREACH(f, tags) {
if (strcmp(f->hmf_name, "channel") == 0 ) { if (strcmp(f->hmf_name, "channel") == 0 ) {
save |= _pyepg_parse_channel(htsmsg_get_map_by_field(f), stats); save |= _pyepg_parse_channel(mod, htsmsg_get_map_by_field(f), stats);
} else if (strcmp(f->hmf_name, "brand") == 0 ) { } else if (strcmp(f->hmf_name, "brand") == 0 ) {
save |= _pyepg_parse_brand(htsmsg_get_map_by_field(f), stats); save |= _pyepg_parse_brand(mod, htsmsg_get_map_by_field(f), stats);
} else if (strcmp(f->hmf_name, "series") == 0 ) { } else if (strcmp(f->hmf_name, "series") == 0 ) {
save |= _pyepg_parse_season(htsmsg_get_map_by_field(f), stats); save |= _pyepg_parse_season(mod, htsmsg_get_map_by_field(f), stats);
} else if (strcmp(f->hmf_name, "episode") == 0 ) { } else if (strcmp(f->hmf_name, "episode") == 0 ) {
save |= _pyepg_parse_episode(htsmsg_get_map_by_field(f), stats); save |= _pyepg_parse_episode(mod, htsmsg_get_map_by_field(f), stats);
} else if (strcmp(f->hmf_name, "schedule") == 0 ) { } else if (strcmp(f->hmf_name, "schedule") == 0 ) {
save |= _pyepg_parse_schedule(htsmsg_get_map_by_field(f), stats); save |= _pyepg_parse_schedule(mod, htsmsg_get_map_by_field(f), stats);
} }
} }
@ -404,7 +411,7 @@ static int _pyepg_parse
/* PyEPG format */ /* PyEPG format */
if ((epg = htsmsg_get_map(tags, "epg")) != NULL) if ((epg = htsmsg_get_map(tags, "epg")) != NULL)
return _pyepg_parse_epg(epg, stats); return _pyepg_parse_epg(mod, epg, stats);
return 0; return 0;
} }

View file

@ -230,7 +230,9 @@ get_episode_info
* job * job
*/ */
static int static int
parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m ) parse_vid_quality
( epggrab_module_t *mod, epg_broadcast_t *ebc, epg_episode_t *ee,
htsmsg_t *m )
{ {
int save = 0; int save = 0;
int hd = 0, lines = 0, aspect = 0; int hd = 0, lines = 0, aspect = 0;
@ -238,7 +240,7 @@ parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
if (!ebc || !m) return 0; if (!ebc || !m) return 0;
if ((str = htsmsg_xml_get_cdata_str(m, "colour"))) if ((str = htsmsg_xml_get_cdata_str(m, "colour")))
save |= epg_episode_set_is_bw(ee, strcmp(str, "no") ? 0 : 1); save |= epg_episode_set_is_bw(ee, strcmp(str, "no") ? 0 : 1, mod);
if ((str = htsmsg_xml_get_cdata_str(m, "quality"))) { if ((str = htsmsg_xml_get_cdata_str(m, "quality"))) {
if (strstr(str, "HD")) { if (strstr(str, "HD")) {
hd = 1; hd = 1;
@ -264,13 +266,13 @@ parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
aspect = (100 * w) / h; aspect = (100 * w) / h;
} }
} }
save |= epg_broadcast_set_is_hd(ebc, hd); save |= epg_broadcast_set_is_hd(ebc, hd, mod);
if (aspect) { if (aspect) {
save |= epg_broadcast_set_is_widescreen(ebc, hd || aspect > 137); save |= epg_broadcast_set_is_widescreen(ebc, hd || aspect > 137, mod);
save |= epg_broadcast_set_aspect(ebc, aspect); save |= epg_broadcast_set_aspect(ebc, aspect, mod);
} }
if (lines) if (lines)
save |= epg_broadcast_set_lines(ebc, lines); save |= epg_broadcast_set_lines(ebc, lines, mod);
return save; return save;
} }
@ -279,7 +281,8 @@ parse_vid_quality ( epg_broadcast_t *ebc, epg_episode_t *ee, htsmsg_t *m )
* Parse accessibility data * Parse accessibility data
*/ */
int int
xmltv_parse_accessibility ( epg_broadcast_t *ebc, htsmsg_t *m ) xmltv_parse_accessibility
( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *m )
{ {
int save = 0; int save = 0;
htsmsg_t *tag; htsmsg_t *tag;
@ -291,12 +294,12 @@ xmltv_parse_accessibility ( epg_broadcast_t *ebc, htsmsg_t *m )
if ((tag = htsmsg_get_map_by_field(f))) { if ((tag = htsmsg_get_map_by_field(f))) {
str = htsmsg_xml_get_attr_str(tag, "type"); str = htsmsg_xml_get_attr_str(tag, "type");
if (str && !strcmp(str, "teletext")) if (str && !strcmp(str, "teletext"))
save |= epg_broadcast_set_is_subtitled(ebc, 1); save |= epg_broadcast_set_is_subtitled(ebc, 1, mod);
else if (str && !strcmp(str, "deaf-signed")) else if (str && !strcmp(str, "deaf-signed"))
save |= epg_broadcast_set_is_deafsigned(ebc, 1); save |= epg_broadcast_set_is_deafsigned(ebc, 1, mod);
} }
} else if (!strcmp(f->hmf_name, "audio-described")) { } else if (!strcmp(f->hmf_name, "audio-described")) {
save |= epg_broadcast_set_is_audio_desc(ebc, 1); save |= epg_broadcast_set_is_audio_desc(ebc, 1, mod);
} }
} }
return save; return save;
@ -323,9 +326,9 @@ static epg_genre_list_t
/** /**
* Parse tags inside of a programme * Parse tags inside of a programme
*/ */
static int static int _xmltv_parse_programme_tags
_xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags, (epggrab_module_t *mod, channel_t *ch, htsmsg_t *tags,
time_t start, time_t stop, epggrab_stats_t *stats) time_t start, time_t stop, epggrab_stats_t *stats)
{ {
int save = 0, save2 = 0; int save = 0, save2 = 0;
epg_episode_t *ee; epg_episode_t *ee;
@ -342,8 +345,11 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
/* Ignore */ /* Ignore */
if (!title) return 0; if (!title) return 0;
/* Build episode */ /*
if (!uri) uri = md5sum(desc ?: title); * Episode
*/
uri = epg_hash(title, NULL, desc);
ee = epg_episode_find_by_uri(uri, 1, &save); ee = epg_episode_find_by_uri(uri, 1, &save);
free(uri); free(uri);
if (!ee) return 0; if (!ee) return 0;
@ -357,16 +363,22 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
free(suri); free(suri);
} }
if (title) save |= epg_episode_set_title(ee, title); if (title)
if (desc) save |= epg_episode_set_description(ee, desc); save |= epg_episode_set_title(ee, title, mod);
if (desc)
save |= epg_episode_set_description(ee, desc, mod);
if ((egl = _xmltv_parse_categories(tags))) { if ((egl = _xmltv_parse_categories(tags))) {
save |= epg_episode_set_genre(ee, egl); save |= epg_episode_set_genre(ee, egl, mod);
epg_genre_list_destroy(egl); epg_genre_list_destroy(egl);
} }
if (pn) save |= epg_episode_set_part(ee, pn, pc); if (pn) save |= epg_episode_set_part(ee, pn, pc, mod);
if (en) save |= epg_episode_set_number(ee, en); if (en) save |= epg_episode_set_number(ee, en, mod);
if (save) stats->episodes.modified++; if (save) stats->episodes.modified++;
/*
* Broadcast
*/
// TODO: need to handle certification and ratings // TODO: need to handle certification and ratings
// TODO: need to handle season numbering! // TODO: need to handle season numbering!
// TODO: need to handle onscreen numbering // TODO: need to handle onscreen numbering
@ -377,20 +389,20 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
if ( ebc ) { if ( ebc ) {
stats->broadcasts.total++; stats->broadcasts.total++;
if (save2) stats->broadcasts.created++; if (save2) stats->broadcasts.created++;
save2 |= epg_broadcast_set_episode(ebc, ee); save2 |= epg_broadcast_set_episode(ebc, ee, mod);
/* Quality metadata */ /* Quality metadata */
save2 |= parse_vid_quality(ebc, ee, htsmsg_get_map(tags, "video")); save2 |= parse_vid_quality(mod, ebc, ee, htsmsg_get_map(tags, "video"));
/* Accessibility */ /* Accessibility */
save2 |= xmltv_parse_accessibility(ebc, tags); save2 |= xmltv_parse_accessibility(mod, ebc, tags);
/* Misc */ /* Misc */
if (htsmsg_get_map(tags, "previously-shown")) if (htsmsg_get_map(tags, "previously-shown"))
save |= epg_broadcast_set_is_repeat(ebc, 1); save |= epg_broadcast_set_is_repeat(ebc, 1, mod);
else if (htsmsg_get_map(tags, "premiere") || else if (htsmsg_get_map(tags, "premiere") ||
htsmsg_get_map(tags, "new")) htsmsg_get_map(tags, "new"))
save |= epg_broadcast_set_is_new(ebc, 1); save |= epg_broadcast_set_is_new(ebc, 1, mod);
/* Stats */ /* Stats */
if (save2) stats->broadcasts.modified++; if (save2) stats->broadcasts.modified++;
@ -402,8 +414,8 @@ _xmltv_parse_programme_tags(channel_t *ch, htsmsg_t *tags,
/** /**
* Parse a <programme> tag from xmltv * Parse a <programme> tag from xmltv
*/ */
static int static int _xmltv_parse_programme
_xmltv_parse_programme(htsmsg_t *body, epggrab_stats_t *stats) (epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
{ {
int save = 0; int save = 0;
htsmsg_t *attribs, *tags; htsmsg_t *attribs, *tags;
@ -421,19 +433,20 @@ _xmltv_parse_programme(htsmsg_t *body, epggrab_stats_t *stats)
if((s = htsmsg_get_str(attribs, "start")) == NULL) return 0; if((s = htsmsg_get_str(attribs, "start")) == NULL) return 0;
start = _xmltv_str2time(s); start = _xmltv_str2time(s);
if((s = htsmsg_get_str(attribs, "stop")) == NULL) return 0; if((s = htsmsg_get_str(attribs, "stop")) == NULL) return 0;
stop = _xmltv_str2time(s); stop = _xmltv_str2time(s);
if(stop <= start || stop < dispatch_clock) return 0; if(stop <= start || stop < dispatch_clock) return 0;
save |= _xmltv_parse_programme_tags(ch->channel, tags, start, stop, stats); save |= _xmltv_parse_programme_tags(mod, ch->channel, tags,
start, stop, stats);
return save; return save;
} }
/** /**
* Parse a <channel> tag from xmltv * Parse a <channel> tag from xmltv
*/ */
static int static int _xmltv_parse_channel
_xmltv_parse_channel(htsmsg_t *body, epggrab_stats_t *stats) (epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
{ {
int save =0; int save =0;
htsmsg_t *attribs, *tags, *subtag; htsmsg_t *attribs, *tags, *subtag;
@ -468,8 +481,8 @@ _xmltv_parse_channel(htsmsg_t *body, epggrab_stats_t *stats)
/** /**
* *
*/ */
static int static int _xmltv_parse_tv
_xmltv_parse_tv(htsmsg_t *body, epggrab_stats_t *stats) (epggrab_module_t *mod, htsmsg_t *body, epggrab_stats_t *stats)
{ {
int save = 0; int save = 0;
htsmsg_t *tags; htsmsg_t *tags;
@ -480,9 +493,9 @@ _xmltv_parse_tv(htsmsg_t *body, epggrab_stats_t *stats)
HTSMSG_FOREACH(f, tags) { HTSMSG_FOREACH(f, tags) {
if(!strcmp(f->hmf_name, "channel")) { if(!strcmp(f->hmf_name, "channel")) {
save |= _xmltv_parse_channel(htsmsg_get_map_by_field(f), stats); save |= _xmltv_parse_channel(mod, htsmsg_get_map_by_field(f), stats);
} else if(!strcmp(f->hmf_name, "programme")) { } else if(!strcmp(f->hmf_name, "programme")) {
save |= _xmltv_parse_programme(htsmsg_get_map_by_field(f), stats); save |= _xmltv_parse_programme(mod, htsmsg_get_map_by_field(f), stats);
} }
} }
return save; return save;
@ -499,7 +512,7 @@ static int _xmltv_parse
if((tv = htsmsg_get_map(tags, "tv")) == NULL) if((tv = htsmsg_get_map(tags, "tv")) == NULL)
return 0; return 0;
return _xmltv_parse_tv(tv, stats); return _xmltv_parse_tv(mod, tv, stats);
} }
/* ************************************************************************ /* ************************************************************************

View file

@ -155,6 +155,7 @@ void xmltv_init ( void );
void xmltv_load ( void ); void xmltv_load ( void );
/* Note: this is reused by pyepg since they share a common format */ /* Note: this is reused by pyepg since they share a common format */
int xmltv_parse_accessibility ( epg_broadcast_t *ebc, htsmsg_t *m ); int xmltv_parse_accessibility
( epggrab_module_t *mod, epg_broadcast_t *ebc, htsmsg_t *m );
#endif /* __EPGGRAB_PRIVATE_H__ */ #endif /* __EPGGRAB_PRIVATE_H__ */