youtube/cli: add "-c channelid" option to list channel videos - frontends - front-ends for some sites (experiment)
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 6623393565f6397c68240f8b77b8f05b87ad9f18
DIR parent ea04b0e0744e1b41f06f4f85effc29ea48eef37c
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 19 Feb 2023 14:40:44 +0100
youtube/cli: add "-c channelid" option to list channel videos
Diffstat:
M youtube/cli.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
---
DIR diff --git a/youtube/cli.c b/youtube/cli.c
@@ -114,7 +114,7 @@ render(struct search_response *r)
static void
usage(const char *argv0)
{
- fprintf(stderr, "usage: %s <keywords>\n", argv0);
+ fprintf(stderr, "usage: %s <keyword> | <-c channelid>\n", argv0);
exit(1);
}
@@ -139,10 +139,15 @@ main(int argc, char *argv[])
if (argc < 2 || !argv[1][0])
usage(argv[0]);
- if (!uriencode(argv[1], search, sizeof(search)))
- usage(argv[0]);
-
- r = youtube_search(search, "", "relevance");
+ if (!strcmp(argv[1], "-c")) {
+ if (argc < 3)
+ usage(argv[0]);
+ r = youtube_channel_videos(argv[2]);
+ } else {
+ if (!uriencode(argv[1], search, sizeof(search)))
+ usage(argv[0]);
+ r = youtube_search(search, "", "relevance");
+ }
if (!r || r->nitems == 0) {
OUT("No videos found\n");
exit(1);