summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/video.h12
-rw-r--r--libs/json.h4
-rw-r--r--queryt.c28
-rw-r--r--src/utils.c8
4 files changed, 33 insertions, 19 deletions
diff --git a/include/video.h b/include/video.h
index e51721d..9ac136d 100644
--- a/include/video.h
+++ b/include/video.h
@@ -1,17 +1,5 @@
#pragma once
-#define TITLE 100
-#define AUTHOR 120
-#define VIDEOID 11
-#define DURATION 8
-
-/*
- * title -> max 100 characters
- * author -> max 120 characters combined
- * video id -> max 11 characters
- * duration -> max 8 characters
- * thumbnail -> https://i.ytimg.com/vi/[id]/hq720.jpg
- */
typedef struct video
{
char *title, *author, *id, *duration;
diff --git a/libs/json.h b/libs/json.h
index 7c3cf05..86cf7bf 100644
--- a/libs/json.h
+++ b/libs/json.h
@@ -1,6 +1,10 @@
#pragma once
#include <json-c/json.h>
#include "../include/video.h"
+#define TITLE 100
+#define AUTHOR 120
+#define VIDEOID 11
+#define DURATION 8
#define MAXLENGTH 256
json_object* jsonParseString(char* stringedJSON);
diff --git a/queryt.c b/queryt.c
index 8f198b0..fb4e918 100644
--- a/queryt.c
+++ b/queryt.c
@@ -7,7 +7,9 @@
#include "include/video.h"
#include "libs/json.h"
-void processOptions(int *options, char **args);
+#define VERSION "1.0"
+
+void processOptions(int *options, char **args, int argc);
int main(int argc, char **argv)
{
@@ -54,7 +56,7 @@ int main(int argc, char **argv)
}
}
- processOptions(opts, args);
+ processOptions(opts, args, argc);
for ( int i = 0; i < 3; i++ )
{
@@ -65,7 +67,7 @@ int main(int argc, char **argv)
return 0;
}
-void processOptions(int *options, char **args)
+void processOptions(int *options, char **args, int argc)
{
if ( !options[1] && options[3] && !options[4] )
{
@@ -123,15 +125,29 @@ void processOptions(int *options, char **args)
}
else
{
- if ( options[1] || (options[3] && options[4]))
+ if ( options[1] || (options[3] && options[4]) || argc == 1)
{
- puts("Help Message");
+ printf("Usage: queryt -s [SEARCH]... [OPTIONS]...\n"
+ "Make youtube querys without authentication or API Key\n\n"
+ " -f, --format format the output query with with custom modifiers\n"
+ " a author;\n"
+ " d duration;\n"
+ " i video id;\n"
+ " t title;\n"
+ " R return;\n"
+ " T tab;\n"
+ " -h, --help display this help and exit\n"
+ " -m, --max defines the max number of displayed results\n"
+ " -s, --search search content on youtube\n"
+ " -v, --version output version information and exit\n\n"
+ "Examples:\n"
+ " queryt -s \"Never Gonna Give You Up\" -m 5 -f iTaTdRt\n\n");
}
else
{
if ( options[4] )
{
- puts("Version Message");
+ printf("queryt-%s\n", VERSION);
}
else
{
diff --git a/src/utils.c b/src/utils.c
index db8eaf3..45735ad 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -216,6 +216,12 @@ void printVideoInfo(char *format, Video *videos, int numberOfVideos)
case 't':
printf("%s", videos[i].title);
break;
+ case 'R':
+ printf("\n");
+ break;
+ case 'T':
+ printf("\t");
+ break;
default:
if( !isalpha(format[j]) )
{
@@ -230,7 +236,7 @@ void printVideoInfo(char *format, Video *videos, int numberOfVideos)
{
for( int i = 0; i < numberOfVideos; i++ )
{
- printf("%s - %s %s %s\n", videos[i].title, videos[i].author, videos[i].duration, videos[i].id);
+ printf("%s\t%s\n", videos[i].id, videos[i].title);
}
}
}