youtube/gopher: improve directory - frontends - front-ends for some sites (expe… | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit fbbbe9242322569b01c1311a0fa634cd801521bb | |
parent 8e7076cc4d88d621e1cab5d35c57a2a2d6e24b51 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 22 Feb 2023 18:42:51 +0100 | |
youtube/gopher: improve directory | |
- Add directory link of its own page, useful for when theres type 7 search. | |
- Show the current search term and add a type 7 search field. | |
- Fix listing the user videos by calling the proper function. | |
- Don't exit(1) even on a Gopher error response. | |
Diffstat: | |
M youtube/gopher.c | 36 ++++++++++++++++++++++++-----… | |
1 file changed, 28 insertions(+), 8 deletions(-) | |
--- | |
diff --git a/youtube/gopher.c b/youtube/gopher.c | |
@@ -63,6 +63,7 @@ render(struct search_response *r) | |
exit(1); | |
header(); | |
+ | |
for (i = 0; i < r->nitems; i++) { | |
if (videos[i].id[0]) | |
putchar('h'); | |
@@ -150,6 +151,7 @@ main(void) | |
{ | |
struct search_response *r = NULL; | |
const char *channelid = "", *userid = "", *querystring = "", *p; | |
+ const char *rawsearch = ""; | |
char search[1024] = ""; | |
if (pledge("stdio dns inet rpath unveil", NULL) == -1) | |
@@ -184,22 +186,40 @@ main(void) | |
p = getenv("X_GOPHER_SEARCH"); /* geomyidae */ | |
if (!p) | |
p = getenv("SEARCHREQUEST"); /* gophernicus */ | |
+ if (p) | |
+ rawsearch = p; | |
if (p && !uriencode(p, search, sizeof(search))) { | |
error("Invalid search"); | |
- printf(".\r\n"); | |
- exit(1); | |
+ footer(); | |
+ return 0; | |
+ } | |
+ | |
+ line('1', "Idiotbox", requestpath); | |
+ info(""); | |
+ | |
+ OUT("7Search"); | |
+ if (rawsearch[0]) { | |
+ OUT(": "); | |
+ OUT(rawsearch); | |
} | |
+ printf("\t%s\t%s\t%s\r\n", requestpath, host, port); | |
- if (search[0]) | |
+ if (search[0]) { | |
r = youtube_search(search, "", "relevance"); | |
- else if (channelid[0]) | |
+ } else if (channelid[0]) { | |
r = youtube_channel_videos(channelid); | |
- else if (userid[0]) | |
- r = youtube_channel_videos(userid); | |
+ } else if (userid[0]) { | |
+ r = youtube_user_videos(userid); | |
+ } else { | |
+ footer(); | |
+ return 0; | |
+ } | |
+ info(""); | |
+ | |
if (!r || r->nitems == 0) { | |
error("No videos found"); | |
- printf(".\r\n"); | |
- exit(1); | |
+ footer(); | |
+ return 0; | |
} | |
render(r); |