diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-26 21:54:57 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-26 21:54:57 +0200 |
commit | 89217bfc20237a4de1011dd4396b892d5db30af0 (patch) | |
tree | c43492145261d2a3fc2b1c8c9930c15bf8de84da | |
parent | 856d564690c858f7c9b92a81e9062328c75f193e (diff) |
Generalized music search.
-rw-r--r-- | music.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -165,18 +165,23 @@ void music_free() { music_root = NULL; } -GSList *music_find_artist_rec(struct directory *directory, const gchar *name) { +static GSList *music_find_rec(struct directory *directory, const gchar *name, enum tag_type type) { GSList *list = NULL; for(GSList *node = directory->sub; node; node = g_slist_next(node)) { struct directory *d = node->data; g_debug("searching in dir %s", d->path); - list = g_slist_concat(list, music_find_artist_rec(d, name)); + list = g_slist_concat(list, music_find_rec(d, name, type)); } for(GSList *node = directory->files; node; node = g_slist_next(node)) { struct file *f = node->data; - gchar *str = g_utf8_casefold(f->name, strlen(f->name)); + const gchar *tag_str = tag_get(f->tag, type); + if(tag_str == NULL) { + continue; + } + + gchar *str = g_utf8_casefold(tag_str, strlen(tag_str)); if(strstr(str, name) != NULL) { list = g_slist_prepend(list, f); } @@ -189,7 +194,7 @@ GSList *music_find_artist_rec(struct directory *directory, const gchar *name) { GSList *music_find_artist(const gchar *_name) { gchar *name = g_utf8_casefold(_name, strlen(_name)); - GSList *list = music_find_artist_rec(music_root, name); + GSList *list = music_find_rec(music_root, name, TAG_TYPE_ARTIST); g_free(name); return list; |