From c3ebe7fe98668098f610b2e38461496f8987aca9 Mon Sep 17 00:00:00 2001 From: jvech Date: Tue, 25 Jan 2022 10:42:22 -0500 Subject: LICENSE and README added --- main.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index bc3a51a..cf811d8 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,21 @@ +/* + * cli-tube, just a simple youtube viewer + * Copyright (C) 2021 vech + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ #include #include #include @@ -121,12 +139,13 @@ int main(int argc, char **argv) char query[TITLE_LENGTH]; if (argc < 2) { - printf("You must provide at least 1 argument not %i\n", argc - 1); + fprintf(stderr, "You must provide at least 1 argument not %i\n", argc - 1); + fprintf(stderr, "Usage: cli-tube ...\n"); exit(1); } argv_concat(query, argv, argc); - char curl_query[TITLE_LENGTH + 43] = {"https://www.youtube.com/results?search_query=algo"}; + char curl_query[TITLE_LENGTH + 43] = {"https://www.youtube.com/results?search_query="}; strcat(curl_query, query); int curl_main_pipe[2]; @@ -141,7 +160,7 @@ int main(int argc, char **argv) } else if (!curl_pid) { close(curl_main_pipe[0]); dup2(curl_main_pipe[1], 1); - if (execlp("curl", "curl", curl_query, NULL) == -1) { + if (execlp("curl", "curl", "--silent",curl_query, NULL) == -1) { error("Can't run curl command"); } } @@ -160,10 +179,14 @@ int main(int argc, char **argv) list *q; int i = 0, index_video; do { + printf( + " ====================================================================\n" + " | YOUTUBE RESULTS |\n" + " ====================================================================\n\n"); for (q = videos->next, i = 1; q != NULL; q = q->next, i++) { - printf("%3d %s\n", i, q->name); + printf("%3d. %s\n", i, q->name); } - printf("Youtube results select one video i=%i: ", i); + printf("Select one video: "); scanf("%d", &index_video); } while (index_video >= i); -- cgit v1.2.3-70-g09d2