Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: internal grabber - add extra arguments config option
  • Loading branch information
perexg committed Nov 8, 2015
1 parent 5fe5abb commit f0c456d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/epggrab.h
Expand Up @@ -170,6 +170,7 @@ struct epggrab_module_int
epggrab_module_t ; ///< Parent object

const char *path; ///< Path for the command
const char *args; ///< Extra arguments

/* Handle data */
char* (*grab) ( void *mod );
Expand Down
25 changes: 22 additions & 3 deletions src/epggrab/module.c
Expand Up @@ -166,6 +166,13 @@ const idclass_t epggrab_class_mod_int = {
.opts = PO_RDONLY | PO_NOSAVE,
.group = 1
},
{
.type = PT_STR,
.id = "args",
.name = N_("Extra arguments"),
.off = offsetof(epggrab_module_int_t, args),
.group = 1
},
{}
}
};
Expand Down Expand Up @@ -318,6 +325,7 @@ epggrab_module_int_t *epggrab_module_int_create
/* Int data */
skel->type = EPGGRAB_INT;
skel->path = strdup(path);
skel->args = strdup("--quiet");
skel->grab = grab ?: epggrab_module_grab_spawn;
skel->trans = trans ?: epggrab_module_trans_xml;
skel->parse = parse;
Expand All @@ -331,19 +339,30 @@ char *epggrab_module_grab_spawn ( void *m )
int rd = -1, outlen;
char *outbuf;
epggrab_module_int_t *mod = m;
char **argv = NULL;
char **argv = NULL;
char *path;

/* Debug */
tvhlog(LOG_INFO, mod->id, "grab %s", mod->path);

/* Quiet */
if (mod->args) {
path = alloca(strlen(mod->path) + strlen(mod->args) + 2);
strcpy(path, mod->path);
strcat(path, " ");
strcat(path, mod->args);
} else {
path = (char *)mod->path;
}

/* Arguments */
if (spawn_parse_args(&argv, 64, mod->path, NULL)) {
if (spawn_parse_args(&argv, 64, path, NULL)) {
tvhlog(LOG_ERR, mod->id, "unable to parse arguments");
return NULL;
}

/* Grab */
outlen = spawn_and_give_stdout(argv[0], (char **)argv, NULL, &rd, NULL, 1);
outlen = spawn_and_give_stdout(argv[0], argv, NULL, &rd, NULL, 1);

spawn_free_args(argv);

Expand Down

2 comments on commit f0c456d

@bluzee
Copy link
Contributor

@bluzee bluzee commented on f0c456d Nov 8, 2015

Choose a reason for hiding this comment

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

It might be safer to leave the extra args blank by default. --quiet breaks some grabbers. Toss up if it's easier to explain why EPG stopped working for some or how to stop the noise in the logs for others.

@perexg
Copy link
Contributor Author

@perexg perexg commented on f0c456d Nov 8, 2015

Choose a reason for hiding this comment

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

Ok, removed in 301c573 .

Please sign in to comment.