youtube: inverse the logic: " ago" is more often found - frontends - front-ends for some sites (experiment)
HTML git clone git://git.codemadness.org/frontends
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit c8e71a9ce9523857678be7445e8f80c5545f9b2c
DIR parent 71b90d9c789fe26693e69d5e6af810f346c3ea39
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 12 May 2026 20:42:12 +0200
youtube: inverse the logic: " ago" is more often found
"views" is not always set. It would sometimes not parse views.
There may be more tweaking required to get it "right" (Youtube JSON output is
illogical).
Diffstat:
M youtube/youtube.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
---
DIR diff --git a/youtube/youtube.c b/youtube/youtube.c
@@ -360,13 +360,12 @@ processnode_search(struct json_node *nodes, size_t depth, const char *value, siz
!strcmp(nodes[depth - 4].name, "metadataParts") &&
!strcmp(nodes[depth - 2].name, "text") &&
!strcmp(nodes[depth - 1].name, "content")) {
- if (strstr(value, "views")) {
- if (value[0] && !item->viewcount[0])
- strlcpy(item->viewcount, value, sizeof(item->viewcount));
- } else if (strstr(value, " ago")) {
+ if (strstr(value, " ago")) {
/* typically second item is published at */
if (value[0] && !item->publishedat[0])
strlcpy(item->publishedat, value, sizeof(item->publishedat));
+ } else if ((value[0] >= '0' && value[0] <= '9') && !item->viewcount[0]) {
+ strlcpy(item->viewcount, value, sizeof(item->viewcount));
}
}