Introduction
Introduction Statistics Contact Development Disclaimer Help
youtube: cgi and gopher: add user parameter - frontends - front-ends for some s…
Log
Files
Refs
README
LICENSE
---
commit 50bc403fd51f83912085837515187a006b4d2dab
parent eec1de3aa027fd3e75101a4829658c2af844fb25
Author: Hiltjo Posthuma <[email protected]>
Date: Wed, 22 Feb 2023 18:17:36 +0100
youtube: cgi and gopher: add user parameter
Afaik this parameter is not used (much) anymore in the search listing though.
Diffstat:
M youtube/cgi.c | 16 +++++++++++++++-
M youtube/gopher.c | 12 +++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/youtube/cgi.c b/youtube/cgi.c
@@ -21,7 +21,7 @@ extern char **environ;
static int curpage = 1;
/* CGI parameters */
-static char rawsearch[4096], search[4096], order[16], page[64], channelid[256];
+static char rawsearch[4096], search[4096], order[16], page[64], channelid[256]…
void
parsecgi(void)
@@ -75,6 +75,12 @@ parsecgi(void)
if (decodeparam(channelid, sizeof(channelid), p) == -1)
channelid[0] = '\0';
}
+
+ /* user ID */
+ if ((p = getparam(query, "user"))) {
+ if (decodeparam(userid, sizeof(userid), p) == -1)
+ userid[0] = '\0';
+ }
}
int
@@ -189,6 +195,12 @@ render(struct search_response *r)
OUT("\">");
xmlencode(videos[i].channeltitle);
OUT("</a>");
+ } else if (videos[i].userid[0]) {
+ OUT("<a href=\"?user=");
+ xmlencode(videos[i].channelid);
+ OUT("\">");
+ xmlencode(videos[i].channeltitle);
+ OUT("</a>");
} else {
xmlencode(videos[i].channeltitle);
}
@@ -286,6 +298,8 @@ main(void)
r = youtube_search(rawsearch, page, order);
else if (channelid[0])
r = youtube_channel_videos(channelid);
+ else if (userid[0])
+ r = youtube_user_videos(userid);
else
goto show;
if (!r || r->nitems == 0) {
diff --git a/youtube/gopher.c b/youtube/gopher.c
@@ -98,6 +98,10 @@ render(struct search_response *r)
OUT("1");
OUT(videos[i].channeltitle);
printf("\t%s?c=%s\t%s\t%s\r\n", requestpath, videos[i]…
+ } else if (videos[i].userid[0]) {
+ OUT("1");
+ OUT(videos[i].channeltitle);
+ printf("\t%s?u=%s\t%s\t%s\r\n", requestpath, videos[i]…
} else if (videos[i].channeltitle[0]) {
OUT("i");
OUT(videos[i].channeltitle);
@@ -145,7 +149,7 @@ int
main(void)
{
struct search_response *r = NULL;
- const char *channelid = "", *querystring = "", *p;
+ const char *channelid = "", *userid = "", *querystring = "", *p;
char search[1024];
if (pledge("stdio dns inet rpath unveil", NULL) == -1)
@@ -169,7 +173,11 @@ main(void)
if (querystring[0] == 'c' && querystring[1] == '=') {
channelid = querystring + 2;
p = querystring = "";
+ } else if (querystring[0] == 'u' && querystring[1] == '=') {
+ userid = querystring + 2;
+ p = querystring = "";
}
+
if (querystring[0])
p = querystring;
if (!p)
@@ -186,6 +194,8 @@ main(void)
r = youtube_search(search, "", "relevance");
else if (channelid[0])
r = youtube_channel_videos(channelid);
+ else if (userid[0])
+ r = youtube_channel_videos(userid);
if (!r || r->nitems == 0) {
error("No videos found");
printf(".\r\n");
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.