diff --git a/doc/lkt.1 b/doc/lkt.1 index 54cdef401d7d38579de35205b1a3abbbac34b3b9..298b7b0a5bb696a7e9aeb4f75b84e1d7b29656c0 100644 --- a/doc/lkt.1 +++ b/doc/lkt.1 @@ -213,19 +213,18 @@ type and the next of the line is the SQL regex that the kara must verify. In SQL regexes, the wildcard is the "%" character and the jocker the character "_". Queries are case insensitive. .PP -Valid types for a query are the following: \fIid\fP, \fIlanguage\fP, or -\fIlang\fP, \fItype\fP, \fIcat\fP or \fIcategory\fP, \fIauthor\fP, \fIquery\fP, -\fIsource\fP and \fItitle\fP. +Valid types for a query are the following: \fIid\fP, \fIlang\fP, \fItype\fP, +\fIcategory\fP, \fIauthor\fP, \fIquery\fP. .PP For the type \fItype\fP, the valid values are the following: \fIOP\fP, \fIED\fP, \fIIS\fP, \fIAMV\fP, \fIVOCA\fP, \fIMV\fP, \fIPV\fP and \fILIVE\fP. .PP -For the type \fIlanguage\fP or \fIlang\fP, the valid values are the following: -\fIjp\fP, \fIfr\fP, \fIsp\fP, \fIen\fP, \fIlatin\fP, \fIit\fP, \fIru\fP, -\fImulti\fP and \fIundefined\fP. +For the type \fIlang\fP, the valid values are the following: \fIjp\fP, +\fIfr\fP, \fIsp\fP, \fIen\fP, \fIlatin\fP, \fIit\fP, \fIru\fP, \fImulti\fP +and \fIundefined\fP. .PP -For the \fIcat\fP or \fIcategory\fP type, the valid values are the following: +For the \fIcategory\fP type, the valid values are the following: \fIvo\fP, \fIva\fP, \fIcdg\fP, \fIamv\fP, \fIvocaloid\fP and \fIautres\fP. .PP Here are some examples of queries: diff --git a/inc/lektor/uri.h b/inc/lektor/uri.h index b9ab50874ab07d438ef3a30bc666c337a9f41348..e9bc81c2a24de53542b0a1aeb624dfb9dc5be9e2 100644 --- a/inc/lektor/uri.h +++ b/inc/lektor/uri.h @@ -5,7 +5,6 @@ #include <stdbool.h> enum lkt_uri_type { - uri_fs, uri_id, uri_playlist, uri_type, diff --git a/src/commands.c b/src/commands.c index a4b34dba0172ee2f7eb35c07706c8e64f748f4b2..9b25a076a3e931fb1bbea1413f4ad677fee17366 100644 --- a/src/commands.c +++ b/src/commands.c @@ -249,13 +249,12 @@ command_stop(volatile sqlite3 *db, struct lkt_win *win, mpd_idle_flag *watch_mas bool command_add(volatile sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], mpd_idle_flag *watch_mask_ptr, int priority) { - RETURN_UNLESS(args, "Invalid argument", false); + RETURN_UNLESS(args && args[0], "Invalid argument", false); *watch_mask_ptr |= MPD_IDLE_PLAYLIST; struct lkt_uri uri; - char *query = args[0]; int ret; /* To be modified according to the command (insert or add) later (TODO) */ UNUSED(win); /* No callbacks to the window for the moment */ - RETURN_UNLESS(lkt_uri_from(&uri, query), "Failed to parse query", false); + RETURN_UNLESS(lkt_uri_from(&uri, args[0]), "Failed to parse query", false); ret = database_queue_add_uri(db, &uri, priority); lkt_uri_free(&uri); if (!ret) @@ -443,20 +442,19 @@ command_find(struct lkt_state *srv, size_t c, char *cmd_args[LKT_MESSAGE_ARGS_MA /* Select the right column */ mpd_tag = cmd_args[0]; - if (STR_MATCH("any", mpd_tag) || STR_MATCH("all", mpd_tag) || STR_MATCH("query", mpd_tag) || - STR_MATCH("source", mpd_tag) || STR_MATCH("title", mpd_tag)) + if (STR_MATCH("query", mpd_tag)) search.name = LKT_DATABASE_KARA_COLUMNT_ANY; else if (STR_MATCH("author", mpd_tag)) search.name = LKT_DATABASE_NAME_KAUTHOR; - else if (STR_MATCH("category", mpd_tag) || STR_MATCH("cat", mpd_tag)) + else if (STR_MATCH("category", mpd_tag)) search.name = LKT_DATABASE_NAME_KCAT; else if (STR_MATCH("type", mpd_tag)) search.name = LKT_DATABASE_NAME_KTYPE; - else if (STR_MATCH("language", mpd_tag) || STR_MATCH("lang", mpd_tag)) + else if (STR_MATCH("lang", mpd_tag)) search.name = LKT_DATABASE_NAME_KLANG; else if (STR_MATCH("id", mpd_tag)) diff --git a/src/database/playlist.c b/src/database/playlist.c index 61b0abf7acf810024fdbc143643c27b31b0b3ce3..e13587814b171a933cda3107cf66669f2c2da8de 100644 --- a/src/database/playlist.c +++ b/src/database/playlist.c @@ -188,7 +188,6 @@ database_plt_add_uri(volatile sqlite3 *db, const char *name, column = LKT_DATABASE_NAME_KLANG; break; case uri_query: - case uri_fs: column = LKT_DATABASE_KARA_ALL; break; default: diff --git a/src/database/queue.c b/src/database/queue.c index e7815cd29e16dc1921275399283e9531bff09bcb..e421ea06f2d080c3583e6f3b51200323568d711c 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -262,7 +262,6 @@ database_queue_add_uri(volatile sqlite3 *db, struct lkt_uri *uri, int priority) { switch (uri->type) { case uri_query: - case uri_fs: return queue_add_with_col_like_str(db, LKT_DATABASE_KARA_ALL, uri->value, priority); case uri_id: diff --git a/src/main/lkt.c b/src/main/lkt.c index c0e0eb3693e68778021f93f1f4f91e2d0d5d6caf..553996d32800edefe8938987781868ebf9b993a0 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -58,14 +58,13 @@ static const char *LKT_QUEUE_DEFAULT[] = { "10" }; static int lkt_valid_type(const char *type) { - return (STR_MATCH(type, "all") || STR_MATCH(type, "any") || STR_MATCH(type, "query") || - STR_MATCH(type, "cat") || STR_MATCH(type, "category") || - STR_MATCH(type, "author") || STR_MATCH(type, "auth") || - STR_MATCH(type, "lang") || STR_MATCH(type, "language") || + return (STR_MATCH(type, "query") || + STR_MATCH(type, "category") || + STR_MATCH(type, "author") || + STR_MATCH(type, "lang") || STR_MATCH(type, "id") || - STR_MATCH(type, "title") || STR_MATCH(type, "type") || - STR_MATCH(type, "source")); + STR_MATCH(type, "playlist")); } static int @@ -317,7 +316,7 @@ queue_replace__(struct lkt_cmd_args *args) sock = lkt_connect(); write_socket(sock, "command_list_begin\n"); write_socket(sock, "clear\n"); - write_socket(sock, "load %s\n", args->argv[0]); + write_socket(sock, "add playlist://%s\n", args->argv[0]); if (play) write_socket(sock, "play\n"); write_socket(sock, "command_list_end\n"); @@ -873,7 +872,6 @@ static struct lkt_cmd_opt options_queue[] = { { .name = "clear", .call = queue_clear__ }, { .name = "crop", .call = queue_crop__ }, { .name = "replace", .call = queue_replace__ }, - { .name = "import", .call = queue_import__ }, LKT_OPT_DEFAULT(queue_list__), }; diff --git a/src/uri.c b/src/uri.c index 82731d39d278d3db4c284b945f3a89800b118340..4a2c61a421d56021ef45b969a518a0e5e06fff9e 100644 --- a/src/uri.c +++ b/src/uri.c @@ -25,28 +25,25 @@ lkt_uri_from(struct lkt_uri *ret, char *const str) if (len <= 5 * sizeof(char)) return false; - if (!strncasecmp(str, "fs", 2 * sizeof(char))) { - ret->type = uri_fs; - val = str + 2; - } else if (!strncasecmp(str, "id", 2 * sizeof(char))) { + if (STR_NMATCH(str, "id", 2)) { ret->type = uri_id; val = str + 2; - } else if (!strncasecmp(str, "plt", 3 * sizeof(char))) { + } else if (STR_NMATCH(str, "playlist", 8)) { ret->type = uri_playlist; val = str + 3; - } else if (!strncasecmp(str, "type", 4 * sizeof(char))) { + } else if (STR_NMATCH(str, "type", 4)) { ret->type = uri_type; val = str + 4; - } else if (!strncasecmp(str, "author", 6 * sizeof(char))) { + } else if (STR_NMATCH(str, "author", 6)) { ret->type = uri_author; val = str + 6; - } else if (!strncasecmp(str, "category", 8 * sizeof(char))) { + } else if (STR_NMATCH(str, "category", 8)) { ret->type = uri_category; val = str + 8; - } else if (!strncasecmp(str, "lang", 4 * sizeof(char))) { + } else if (STR_NMATCH(str, "lang", 4)) { ret->type = uri_language; val = str + 4; - } else if (!strncasecmp(str, "query", 5 * sizeof(char))) { + } else if (STR_NMATCH(str, "query", 5)) { ret->type = uri_query; val = str + 5; } else