diff --git a/omdb.c b/omdb.c index 8d0b769..b64c5c3 100644 --- a/omdb.c +++ b/omdb.c @@ -188,6 +188,7 @@ int handle_response(struct response *restrict resp) { int main(int argc, char **argv) { int ch; + bool i_flag = false; bool k_flag = false; char search_mode[8] = "movie"; @@ -204,11 +205,12 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - while ((ch = getopt_long(argc, argv, "hijk:ft:y:", opts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "hi:jk:ft:y:", opts, NULL)) != -1) { switch (ch) { case 'i': /* Lookup by ID */ - set_param(url, "id", optarg); + i_flag = true; + set_param(url, "i", optarg); break; case 'j': output_format = OUTPUT_JSON; @@ -245,16 +247,15 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - // printf("Looking for: %s\n", argv[optind]); - /* Set remaining params if any... */ set_param(url, "type", search_mode); set_param(url, "r", "json"); /* Search for title... */ - set_param(url, "t", argv[optind]); + if (i_flag == false) + set_param(url, "t", argv[optind]); /* Print it... */ - // print_url(url); + /* print_url(url); */ /* * All of the call setup should be done via the URL so all that's left is to