XMTTV: allow to specify arguments for grabbers, fixes #2516

This commit is contained in:
Jaroslav Kysela 2014-12-01 20:18:05 +01:00
parent bb31907761
commit 6b152b942d
2 changed files with 31 additions and 3 deletions

View file

@ -282,13 +282,31 @@ char *epggrab_module_grab_spawn ( void *m )
int rd = -1, outlen;
char *outbuf;
epggrab_module_int_t *mod = m;
const char *argv[] = { NULL, "--quiet", NULL };
char **argv = NULL;
char *dargv[] = { (char *)mod->path, (char *)"--quiet", NULL };
/* Debug */
tvhlog(LOG_INFO, mod->id, "grab %s", mod->path);
/* Arguments */
if (spawn_parse_args(&argv, 64, mod->path, NULL)) {
tvhlog(LOG_ERR, mod->id, "unable to parse arguments");
return NULL;
}
if (argv && argv[1] == NULL) {
spawn_free_args(argv);
argv = dargv;
} else {
/* -- means no arguments */
if (argv && !strcmp(argv[1], "--") && argv[2] == NULL) {
free(argv[1]);
argv[1] = NULL;
}
}
/* Grab */
outlen = spawn_and_give_stdout(mod->path, (char **)argv, NULL, &rd, NULL, 1);
outlen = spawn_and_give_stdout(argv[0], (char **)argv, NULL, &rd, NULL, 1);
if (outlen < 0)
goto error;
@ -299,9 +317,14 @@ char *epggrab_module_grab_spawn ( void *m )
close(rd);
if (argv != dargv)
spawn_free_args(argv);
return outbuf;
error:
if (argv && argv != dargv)
spawn_free_args(argv);
if (rd >= 0)
close(rd);
tvhlog(LOG_ERR, mod->id, "no output detected");

View file

@ -696,8 +696,13 @@ static void _xmltv_load_grabbers ( void )
outbuf[i] = '\0';
sprintf(name, "XMLTV: %s", &outbuf[n]);
epggrab_module_int_create(NULL, &outbuf[p], name, 3, &outbuf[p],
NULL, _xmltv_parse, NULL, NULL);
NULL, _xmltv_parse, NULL, NULL);
p = n = i + 1;
} else if ( outbuf[i] == '\\') {
memmove(outbuf, outbuf + 1, strlen(outbuf));
if (outbuf[i])
i++;
continue;
} else if ( outbuf[i] == '|' ) {
outbuf[i] = '\0';
n = i + 1;