Introduction
Introduction Statistics Contact Development Disclaimer Help
youtube/cli: enable to sort via the command-line - frontends - front-ends for s…
Log
Files
Refs
README
LICENSE
---
commit d76cca97c957bab0b2a8dca7554837831522a8b6
parent 3079e32c8a2abdcb8b896e9fd32c0c0f6a407e59
Author: Hiltjo Posthuma <[email protected]>
Date: Fri, 5 May 2023 11:37:43 +0200
youtube/cli: enable to sort via the command-line
Only works with keywords search.
Diffstat:
M youtube/cli.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/youtube/cli.c b/youtube/cli.c
@@ -320,7 +320,7 @@ render_video(struct video_response *r)
static void
usage(const char *argv0)
{
- fprintf(stderr, "usage: %s [-t] <keyword> | <-c channelid> | <-u user>…
+ fprintf(stderr, "usage: %s [-t] <keyword> | <-c channelid> | <-u user>…
exit(1);
}
@@ -331,6 +331,7 @@ main(int argc, char *argv[])
struct video_response *vr = NULL;
char search[1024];
const char *keywords = NULL, *channelid = NULL, *user = NULL, *videoid…
+ const char *order = "relevance";
int i, usetsv = 0;
if (pledge("stdio dns inet rpath unveil", NULL) == -1) {
@@ -353,6 +354,12 @@ main(int argc, char *argv[])
videoid = argv[i + 1];
i++;
break;
+ case 'o':
+ if (i + 1 >= argc)
+ usage(argv[0]);
+ order = argv[i + 1];
+ i++;
+ break;
case 'u':
if (i + 1 >= argc)
usage(argv[0]);
@@ -381,6 +388,13 @@ main(int argc, char *argv[])
if (argc < 2 || !argv[1][0])
usage(argv[0]);
+
+ /* check order options */
+ if (strcmp(order, "relevance") &&
+ strcmp(order, "views") &&
+ strcmp(order, "rating"))
+ usage(argv[0]);
+
if (channelid) {
r = youtube_channel_videos(channelid);
} else if (user) {
@@ -396,7 +410,7 @@ main(int argc, char *argv[])
} else if (keywords) {
if (!uriencode(keywords, search, sizeof(search)))
usage(argv[0]);
- r = youtube_search(search, "", "relevance");
+ r = youtube_search(search, "", order);
}
if (!r || r->nitems == 0) {
OUT("No videos found\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.