youtube/feed: add members only prefix and make it a macro - frontends - front-ends for some sites (experiment)
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 22b96ef52894b9382d29b3a387afbd1a00327ce9
(DIR) parent fa4e5a13ff43b7e0d7849355c2b5b3334da5c9b3
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 19 Oct 2025 14:21:01 +0200
youtube/feed: add members only prefix and make it a macro
This makes it easy to change the text or set it empty if wanted.
Currently for youtube/feed: as far as I know members only videos are not
visible in the Youtube Atom feed anyway.
Diffstat:
M youtube/cgi.c | 2 +-
M youtube/feed.c | 13 ++++++++++++-
M youtube/gopher.c | 2 +-
M youtube/youtube.h | 3 +++
4 files changed, 17 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/youtube/cgi.c b/youtube/cgi.c
@@ -213,7 +213,7 @@ render_search(struct search_response *r)
}
if (v->membersonly)
- OUT("[Members only] ");
+ xmlencode(MEMBERS_ONLY);
switch (v->linktype) {
case Channel:
(DIR) diff --git a/youtube/feed.c b/youtube/feed.c
@@ -460,6 +460,8 @@ atom_item(void)
return;
fputs("<entry>\n\t<title>", stdout);
+ if (found->membersonly)
+ xmlencode(MEMBERS_ONLY);
xmlencode(ctx.fields[FeedFieldTitle].str.data);
if (found->duration[0]) {
fputs(" [", stdout);
@@ -546,8 +548,9 @@ html_item(void)
fputs("\">", stdout);
}
+ if (found->membersonly)
+ xmlencode(MEMBERS_ONLY);
xmlencode(ctx.fields[FeedFieldTitle].str.data);
-
if (found->duration[0]) {
fputs(" [", stdout);
xmlencode(found->duration);
@@ -600,6 +603,8 @@ gph_item(void)
/* just print the original timestamp, it should conform */
gphencode(ctx.fields[FeedFieldTime].str.data);
fputs(" ", stdout);
+ if (found->membersonly)
+ gphencode(MEMBERS_ONLY);
gphencode(ctx.fields[FeedFieldTitle].str.data);
if (found->duration[0]) {
fputs(" [", stdout);
@@ -679,6 +684,8 @@ json_item(void)
fputs("\"", stdout);
fputs(",\n\t\"title\": \"", stdout);
+ if (found->membersonly)
+ json_printfield(MEMBERS_ONLY);
json_printfield(ctx.fields[FeedFieldTitle].str.data);
if (found->duration[0]) {
fputs(" [", stdout);
@@ -726,6 +733,8 @@ sfeed_item(void)
string_print_timestamp(&ctx.fields[FeedFieldTime].str);
putchar(FieldSeparator);
+ if (found->membersonly)
+ fputs(MEMBERS_ONLY, stdout);
string_print(&ctx.fields[FeedFieldTitle].str);
if (found->duration[0]) {
fputs(" [", stdout);
@@ -771,6 +780,8 @@ twtxt_item(void)
string_print(&ctx.fields[FeedFieldTime].str);
putchar(FieldSeparator);
+ if (found->membersonly)
+ fputs(MEMBERS_ONLY, stdout);
string_print(&ctx.fields[FeedFieldTitle].str);
if (found->duration[0]) {
fputs(" [", stdout);
(DIR) diff --git a/youtube/gopher.c b/youtube/gopher.c
@@ -77,7 +77,7 @@ render_search(struct search_response *r)
putchar('i');
if (v->membersonly)
- OUT("[Members only] ");
+ OUTTEXT(MEMBERS_ONLY);
switch (v->linktype) {
case Channel:
(DIR) diff --git a/youtube/youtube.h b/youtube/youtube.h
@@ -1,3 +1,6 @@
+/* prefix for members-only in titles */
+#define MEMBERS_ONLY "[Members only] "
+
struct item {
enum LinkType { Unknown = 0, Channel, Movie, Playlist, Video } linktype;
char id[32];