46 |
46 |
#define EIT_SPEC_NZ_FREEVIEW 2
|
47 |
47 |
#define EIT_SPEC_UK_CABLE_VIRGIN 3
|
48 |
48 |
|
|
49 |
typedef struct eit_genre_regex
|
|
50 |
{
|
|
51 |
uint8_t genre; ///< Genre code from epg.c
|
|
52 |
eit_pattern_list_t p_genre; ///< Regex across fields to match this genre.
|
|
53 |
} eit_genre_regex_t;
|
49 |
54 |
|
50 |
55 |
/* Provider configuration */
|
51 |
56 |
typedef struct eit_module_t
|
... | ... | |
55 |
60 |
eit_pattern_list_t p_enum;
|
56 |
61 |
eit_pattern_list_t p_airdate; ///< Original air date parser
|
57 |
62 |
eit_pattern_list_t p_scrape_subtitle;///< Scrape subtitle from summary data
|
|
63 |
int num_eit_genre_regex;
|
|
64 |
eit_genre_regex_t *eit_genres;
|
58 |
65 |
} eit_module_t;
|
59 |
66 |
|
60 |
67 |
/* ************************************************************************
|
... | ... | |
483 |
490 |
return changed;
|
484 |
491 |
}
|
485 |
492 |
|
|
493 |
/* Genre is handle differently to others in that we build
|
|
494 |
* up lists of genres in the event and then afterwards if the
|
|
495 |
* list exists we then see if the entire list has changed.
|
|
496 |
*/
|
|
497 |
static void
|
|
498 |
_eit_scrape_genre(const char *str,
|
|
499 |
eit_module_t *eit_mod,
|
|
500 |
eit_event_t *ev)
|
|
501 |
{
|
|
502 |
if (!str || !*str) return;
|
|
503 |
if (!eit_mod->num_eit_genre_regex) return;
|
|
504 |
|
|
505 |
char buffer[2048];
|
|
506 |
int i = 0;
|
|
507 |
for (; i < eit_mod->num_eit_genre_regex; ++i) {
|
|
508 |
eit_genre_regex_t *egr = &eit_mod->eit_genres[i];
|
|
509 |
if (eit_pattern_apply_list(buffer, sizeof(buffer), str, &egr->p_genre)) {
|
|
510 |
if (!ev->genre) ev->genre = calloc(1, sizeof(epg_genre_list_t));
|
|
511 |
epg_genre_list_add_by_eit(ev->genre, egr->genre);
|
|
512 |
}
|
|
513 |
}
|
|
514 |
}
|
|
515 |
|
486 |
516 |
|
487 |
517 |
/* ************************************************************************
|
488 |
518 |
* EIT Event
|
... | ... | |
678 |
708 |
eit_mod, &en, &first_aired);
|
679 |
709 |
}
|
680 |
710 |
|
|
711 |
if (eit_mod->scrape_genre) {
|
|
712 |
/* Genre scraping builds up a list in ev.genre so has no
|
|
713 |
* "scraped" value here to check.
|
|
714 |
*/
|
|
715 |
if (ev.title)
|
|
716 |
_eit_scrape_genre(lang_str_get(ev.title, ev.default_charset),
|
|
717 |
eit_mod, &ev);
|
|
718 |
if (ev.desc)
|
|
719 |
_eit_scrape_genre(lang_str_get(ev.desc, ev.default_charset),
|
|
720 |
eit_mod, &ev);
|
|
721 |
|
|
722 |
if (ev.summary)
|
|
723 |
_eit_scrape_genre(lang_str_get(ev.summary, ev.default_charset),
|
|
724 |
eit_mod, &ev);
|
|
725 |
}
|
|
726 |
|
681 |
727 |
/* Update Episode */
|
682 |
728 |
if (ee) {
|
683 |
729 |
*save |= epg_broadcast_set_episode(ebc, ee, &changes2);
|
... | ... | |
1062 |
1108 |
eit_pattern_free_list(&mod->p_enum);
|
1063 |
1109 |
eit_pattern_free_list(&mod->p_airdate);
|
1064 |
1110 |
eit_pattern_free_list(&mod->p_scrape_subtitle);
|
|
1111 |
mod->num_eit_genre_regex = 0;
|
|
1112 |
free(mod->eit_genres);
|
|
1113 |
}
|
|
1114 |
|
|
1115 |
static void _eit_scrape_load_genre_regex(htsmsg_t *m, eit_module_t *mod)
|
|
1116 |
{
|
|
1117 |
htsmsg_field_t *f;
|
|
1118 |
HTSMSG_FOREACH(f, m) {
|
|
1119 |
htsmsg_t *value;
|
|
1120 |
if (!strncmp(f->hmf_name, "genre_", 6) && (value = htsmsg_get_list_by_field(f))) {
|
|
1121 |
int genre_int;
|
|
1122 |
if (sscanf(f->hmf_name, "genre_%x", &genre_int) == 1) {
|
|
1123 |
/* One item parsed, this is the hex category code */
|
|
1124 |
if (genre_int < 0 || genre_int > 255)
|
|
1125 |
continue;
|
|
1126 |
++mod->num_eit_genre_regex;
|
|
1127 |
mod->eit_genres = realloc(mod->eit_genres,
|
|
1128 |
mod->num_eit_genre_regex * sizeof(eit_genre_regex_t));
|
|
1129 |
eit_genre_regex_t *egr = &mod->eit_genres[mod->num_eit_genre_regex - 1];
|
|
1130 |
egr->genre = genre_int;
|
|
1131 |
eit_pattern_compile_list(&egr->p_genre, value);
|
|
1132 |
}
|
|
1133 |
}
|
|
1134 |
}
|
1065 |
1135 |
}
|
1066 |
1136 |
|
1067 |
1137 |
static int _eit_scrape_load_one ( htsmsg_t *m, eit_module_t* mod )
|
... | ... | |
1076 |
1146 |
eit_pattern_compile_list(&mod->p_scrape_subtitle, htsmsg_get_list(m, "scrape_subtitle"));
|
1077 |
1147 |
}
|
1078 |
1148 |
|
|
1149 |
if (mod->scrape_genre) {
|
|
1150 |
_eit_scrape_load_genre_regex(m, mod);
|
|
1151 |
}
|
1079 |
1152 |
return 1;
|
1080 |
1153 |
}
|
1081 |
1154 |
|