summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--music.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/music.c b/music.c
index 0bbaa0f..0f6656a 100644
--- a/music.c
+++ b/music.c
@@ -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;