From 0334269989c4dd72cca73181e4cdc34afdbbf860 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 16 Jan 2021 09:31:46 +0100 Subject: [PATCH] [mpd] Support search/find/count with `modified-since` filter criteria --- src/mpd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mpd.c b/src/mpd.c index 8ae3156b..a8e4f7f9 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -192,6 +192,7 @@ static struct mpd_tagtype tagtypes[] = { "file", NULL, NULL, NULL, MPD_TYPE_SPECIAL, -1, true, }, { "base", NULL, NULL, NULL, MPD_TYPE_SPECIAL, -1, true, }, { "any", NULL, NULL, NULL, MPD_TYPE_SPECIAL, -1, true, }, + { "modified-since", NULL, NULL, NULL, MPD_TYPE_SPECIAL, -1, true, }, }; @@ -738,6 +739,14 @@ parse_filter_window_params(int argc, char **argv, bool exact_match, struct query { c1 = db_mprintf("(f.virtual_path LIKE '/%q%%')", argv[i + 1]); } + else if (0 == strcasecmp(tagtype->tag, "modified-since")) + { + // according to the mpd protocol specification the value can be a unix timestamp or ISO 8601 + if (strchr(argv[i + 1], '-') == NULL) + c1 = db_mprintf("(f.time_modified > strftime('%%s', datetime('%q', 'unixepoch')))", argv[i + 1]); + else + c1 = db_mprintf("(f.time_modified > strftime('%%s', datetime('%q', 'utc')))", argv[i + 1]); + } else { DPRINTF(E_WARN, L_MPD, "Unknown special parameter '%s' will be ignored\n", tagtype->tag);