Searching by imdb id works now.

This commit is contained in:
Micheal Smith 2026-01-09 04:52:45 -06:00
parent 2134029904
commit 15657f7ba6
Signed by: xulfer
GPG key ID: E40750BFE6702504

11
omdb.c
View file

@ -188,6 +188,7 @@ int handle_response(struct response *restrict resp) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ch; int ch;
bool i_flag = false;
bool k_flag = false; bool k_flag = false;
char search_mode[8] = "movie"; char search_mode[8] = "movie";
@ -204,11 +205,12 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE); 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) { switch (ch) {
case 'i': case 'i':
/* Lookup by ID */ /* Lookup by ID */
set_param(url, "id", optarg); i_flag = true;
set_param(url, "i", optarg);
break; break;
case 'j': case 'j':
output_format = OUTPUT_JSON; output_format = OUTPUT_JSON;
@ -245,16 +247,15 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// printf("Looking for: %s\n", argv[optind]);
/* Set remaining params if any... */ /* Set remaining params if any... */
set_param(url, "type", search_mode); set_param(url, "type", search_mode);
set_param(url, "r", "json"); set_param(url, "r", "json");
/* Search for title... */ /* Search for title... */
if (i_flag == false)
set_param(url, "t", argv[optind]); set_param(url, "t", argv[optind]);
/* Print it... */ /* 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 * All of the call setup should be done via the URL so all that's left is to