static int api_dvr_autorec_create ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) { htsmsg_t *conf; dvr_config_t *cfg; dvr_autorec_entry_t *dae; const char *s1; if (!(conf = htsmsg_get_map(args, "conf"))) return EINVAL; htsmsg_set_str(conf, "owner", perm->aa_username ?: ""); htsmsg_set_str(conf, "creator", perm->aa_representative ?: ""); s1 = htsmsg_get_str(conf, "config_uuid"); if (s1 == NULL) s1 = htsmsg_get_str(conf, "config_name"); pthread_mutex_lock(&global_lock); cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, s1); if (cfg) { htsmsg_set_str(conf, "config_name", idnode_uuid_as_str(&cfg->dvr_id)); dae = dvr_autorec_create(NULL, conf); if (dae) { dvr_autorec_save(dae); dvr_autorec_changed(dae, 1); } } pthread_mutex_unlock(&global_lock); return 0; }
static int api_dvr_autorec_create ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) { htsmsg_t *conf; dvr_autorec_entry_t *dae; if (!(conf = htsmsg_get_map(args, "conf"))) return EINVAL; if (perm->aa_username) htsmsg_set_str(conf, "owner", perm->aa_username); if (perm->aa_representative) htsmsg_set_str(conf, "creator", perm->aa_representative); pthread_mutex_lock(&global_lock); dae = dvr_autorec_create(NULL, conf); if (dae) { dvr_autorec_save(dae); dvr_autorec_changed(dae, 1); } pthread_mutex_unlock(&global_lock); return 0; }
static int api_dvr_autorec_create_by_series ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) { dvr_autorec_entry_t *dae; epg_broadcast_t *e; htsmsg_t *entries, *entries2 = NULL, *m; htsmsg_field_t *f; const char *config_uuid, *s; int count = 0; if (!(entries = htsmsg_get_list(args, "entries"))) { entries = entries2 = api_dvr_entry_create_from_single(args); if (!entries) return EINVAL; } HTSMSG_FOREACH(f, entries) { if (!(m = htsmsg_get_map_by_field(f))) continue; if (!(s = htsmsg_get_str(m, "event_id"))) continue; config_uuid = htsmsg_get_str(m, "config_uuid"); pthread_mutex_lock(&global_lock); if ((e = epg_broadcast_find_by_id(strtoll(s, NULL, 10)))) { dvr_config_t *cfg = dvr_config_find_by_list(perm->aa_dvrcfgs, config_uuid); if (cfg) { dae = dvr_autorec_add_series_link(idnode_uuid_as_str(&cfg->dvr_id), e, perm->aa_username, perm->aa_representative, "Created from EPG query"); if (dae) { dvr_autorec_save(dae); dvr_autorec_changed(dae, 1); } } } pthread_mutex_unlock(&global_lock); count++; } htsmsg_destroy(entries2); return !count ? EINVAL : 0; }