#include "epg.h"
#include "epggrab.h"
#include "epggrab/private.h"
+#include "eitpatternlist.h"
#include "input.h"
#include "input/mpegts/dvb_charset.h"
#include "dvr/dvr.h"
#define EIT_SPEC_UK_FREESAT 1
#define EIT_SPEC_NZ_FREEVIEW 2
+
+/* Provider configuration */
+typedef struct eit_module_t
+{
+ epggrab_module_ota_t ; ///< Base struct
+ eit_pattern_list_t p_snum;
+ eit_pattern_list_t p_enum;
+} eit_module_t;
+
/* ************************************************************************
* Status handling
* ***********************************************************************/
const uint8_t *ptr, int len,
int local, int *resched, int *save )
{
+ eit_module_t* eit_mod = (eit_module_t*)mod;
int dllen, save2 = 0, rsonly = 0;
time_t start, stop;
uint16_t eid;
ee = epg_episode_find_by_broadcast(ebc, mod, 1, save, &changes4);
}
+ epg_episode_num_t en;
+ memset(&en, 0, sizeof(en));
+
+ if (ev.summary) {
+ /* search for season number */
+ char buffer[2048];
+ const char* summary = lang_str_get(ev.summary, ev.default_charset);
+ if (eit_pattern_apply_list(buffer, sizeof(buffer), summary, &eit_mod->p_snum))
+ if ((en.s_num = atoi(buffer)))
+ tvhtrace(LS_TBL_EIT," extract season number %d using %s", en.s_num, mod->id);
+ /* ...for episode number */
+ if (eit_pattern_apply_list(buffer, sizeof(buffer), summary, &eit_mod->p_enum))
+ if ((en.e_num = atoi(buffer)))
+ tvhtrace(LS_TBL_EIT," extract episode number %d using %s", en.e_num, mod->id);
+ }
+
/* Update Episode */
if (ee) {
*save |= epg_broadcast_set_episode(ebc, ee, &changes2);
if (ev.extra)
*save |= epg_episode_set_extra(ee, extra, &changes4);
#endif
+ /* save any found episode number */
+ if (en.s_num || en.e_num || en.p_num)
+ *save |= epg_episode_set_epnum(ee, &en, &changes4);
*save |= epg_episode_change_finish(ee, changes4, 0);
}
return r;
}
+static int _eit_fixup_load_one ( htsmsg_t *m, eit_module_t* mod )
+{
+ eit_pattern_compile_list(&mod->p_snum, htsmsg_get_list(m, "season_num"));
+ eit_pattern_compile_list(&mod->p_enum, htsmsg_get_list(m, "episode_num"));
+ return 1;
+}
+
+static eit_module_t *eit_module_ota_create
+ ( const char *id, int subsys, const char *saveid,
+ const char *name, int priority,
+ epggrab_ota_module_ops_t *ops )
+{
+ eit_module_t * mod = (eit_module_t *)
+ epggrab_module_ota_create(calloc(1, sizeof(eit_module_t)),
+ id, subsys, saveid,
+ name, priority, ops);
+
+ const char config_path[] = "epggrab/eit/fixup/%s";
+ const char *config_file = id;
+
+ /* Attempt to load config file based on grabber id such as
+ * uk_freeview.
+ */
+ htsmsg_t *m = hts_settings_load(config_path, config_file);
+ char *generic_name = NULL;
+ if (!m) {
+ /* No config file so try loading a generic config based on
+ * the first component of the id. In the above case it would
+ * be "uk". This allows config for a country to be shared across
+ * two grabbers such as DVB-T and DVB-S.
+ */
+ generic_name = strdup(id);
+ if (generic_name) {
+ char *underscore = strstr(generic_name, "_");
+ if (underscore) {
+ /* Terminate the string at the underscore */
+ *underscore = 0;
+ config_file = generic_name;
+ m = hts_settings_load(config_path, config_file);
+ }
+ }
+ }
+
+ if (m) {
+ const int r = _eit_fixup_load_one(m, mod);
+ if (r > 0)
+ tvhinfo(LS_TBL_EIT, "fixup %s loaded %s", id, config_file);
+ else
+ tvhwarn(LS_TBL_EIT, "fixup %s failed", id);
+ htsmsg_destroy(m);
+ } else {
+ tvhinfo(LS_TBL_EIT, "no fixup config files loaded for %s", id);
+ }
+
+ if (generic_name)
+ free(generic_name);
+
+ return mod;
+}
+
#define EIT_OPS(name, _pid, _conv, _spec) \
static eit_private_t opaque_##name = { \
.pid = (_pid), \
}
#define EIT_CREATE(id, name, prio, ops) \
- epggrab_module_ota_create(NULL, id, LS_TBL_EIT, NULL, name, prio, ops)
+ eit_module_ota_create(id, LS_TBL_EIT, NULL, name, prio, ops)
void eit_init ( void )
{