Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
XMTTV: allow to specify arguments for grabbers, fixes #2516
  • Loading branch information
perexg committed Dec 1, 2014
1 parent bb31907 commit 6b152b9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
27 changes: 25 additions & 2 deletions src/epggrab/module.c
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
7 changes: 6 additions & 1 deletion src/epggrab/module/xmltv.c
Expand Up @@ -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;
Expand Down

5 comments on commit 6b152b9

@bluzee
Copy link
Contributor

@bluzee bluzee commented on 6b152b9 Dec 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does one specify the arguments? It's still sending --quiet and for the life of me I can't see where to change that either in the UI or on the command line.

@perexg
Copy link
Contributor Author

@perexg perexg commented on 6b152b9 Dec 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create 'tv_find_grabbers' executable which will sent this to stdout:

PRG ARG1 ARG2 ...|Grabber description

When ARG1 == '--' no arguments will be used for the executable.

@bluzee
Copy link
Contributor

@bluzee bluzee commented on 6b152b9 Dec 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might break xmltv for any other applications besides tvh one might use it with. Do you really want to tell people that they have to rewrite xmltv on their system every time someone writes in and complains they can't get a grabber to work with tvh? It would probably work better to have people who want to run --quiet rewrite their xmltv instead. That way nothing gets broken.

@perexg
Copy link
Contributor Author

@perexg perexg commented on 6b152b9 Dec 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this ping-pong (frustrated enough to convice people that --quiet is good thing to distintct between the standard command line run and the application run). I removed --quiet - 7db9f44 which will mean another bug-reports that xmltv grabbers are noisy on stderr ....

@bluzee
Copy link
Contributor

@bluzee bluzee commented on 6b152b9 Dec 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, it was worth a shot. Noisy xmltv grabbers is not a TVH bug. Adding --quiet would probably be a nice feature but there is no way to control which grabbers support --quiet now or in the future. To safely add it in would need new feature in UI to allow extra args to be specified or if you just want to support --quiet only then an on/off toggle in the UI.

Please sign in to comment.