Skip to content

Commit

Permalink
Feat: configurable track number for covergrid backend search #200
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Feb 11, 2020
1 parent 1c117c8 commit 8bfa485
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ static int mympd_inihandler(void *user, const char *section, const char *name, c
else if (MATCH("mympd", "bookmarks")) {
p_config->bookmarks = strtobool(value);
}
else if (MATCH("mympd", "covergridminsongs")) {
p_config->covergridminsongs = strtoimax(value, &crap, 10);
}
else if (MATCH("theme", "theme")) {
p_config->theme = sdsreplace(p_config->theme, value);
}
Expand Down Expand Up @@ -308,7 +311,7 @@ static void mympd_get_env(struct t_config *config) {
"MYMPD_PAGINATION", "MYMPD_LASTPLAYEDCOUNT", "MYMPD_LOVE", "MYMPD_LOVECHANNEL", "MYMPD_LOVEMESSAGE",
"MYMPD_NOTIFICATIONWEB", "MYMPD_CHROOT", "MYMPD_READONLY", "MYMPD_TIMER",
"MYMPD_NOTIFICATIONPAGE", "MYMPD_AUTOPLAY", "MYMPD_JUKEBOXMODE", "MYMPD_BOOKMARKS",
"MYMPD_MEDIASESSION",
"MYMPD_MEDIASESSION", "MYMPD_COVERGRIDMINSONGS",
"MYMPD_JUKEBOXPLAYLIST", "MYMPD_JUKEBOXQUEUELENGTH", "MYMPD_JUKEBOXLASTPLAYED",
"MYMPD_JUKEBOXUNIQUETAG", "MYMPD_COLSQUEUECURRENT","MYMPD_COLSSEARCH",
"MYMPD_COLSBROWSEDATABASE", "MYMPD_COLSBROWSEPLAYLISTDETAIL",
Expand Down Expand Up @@ -446,6 +449,7 @@ void mympd_config_defaults(t_config *config) {
config->regex = true;
config->timer = true;
config->sticker_cache = true;
config->covergridminsongs = 1;
list_init(&config->syscmd_list);
}

Expand Down Expand Up @@ -547,7 +551,8 @@ bool mympd_dump_config(void) {
"streamport = %d\n"
"#streamuri = %s\n"
"readonly = %s\n"
"bookmarks = %s\n\n",
"bookmarks = %s\n"
"covergridminsongs = %d\n\n",
p_config->user,
(p_config->chroot == true ? "true" : "false"),
p_config->varlibdir,
Expand Down Expand Up @@ -594,7 +599,8 @@ bool mympd_dump_config(void) {
p_config->stream_port,
p_config->stream_url,
(p_config->readonly == true ? "true" : "false"),
(p_config->bookmarks == true ? "true" : "false")
(p_config->bookmarks == true ? "true" : "false"),
p_config->covergridminsongs
);

fprintf(fp, "[theme]\n"
Expand Down
1 change: 1 addition & 0 deletions src/config_defs.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ typedef struct t_config {
bool timer;
bool sticker_cache;
sds generate_pls_tags;
int covergridminsongs;
//system commands
struct list syscmd_list;
} t_config;
Expand Down
2 changes: 1 addition & 1 deletion src/mpd_client/mpd_client_browse.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ sds mpd_client_put_firstsong_in_albums(t_config *config, t_mpd_state *mpd_state,
buffer = check_error_and_recover(mpd_state, buffer, method, request_id);
return buffer;
}
sds expression = sdsnew("((Track == '1')");
sds expression = sdscatprintf(sdsempty(), "((Track == '%d')", config->covergridminsongs);
int searchstr_len = strlen(searchstr);
if (config->regex == true && searchstr_len > 0 && searchstr_len <= 2 && strlen(tag) > 0) {
expression = sdscatfmt(expression, " AND (%s =~ '^%s')", tag, searchstr);
Expand Down

0 comments on commit 8bfa485

Please sign in to comment.