diff --git a/core/tags/artist.c b/core/tags/artist.c index bdb0f2fb..14d360c9 100644 --- a/core/tags/artist.c +++ b/core/tags/artist.c @@ -94,6 +94,11 @@ int artist_compare(struct artist *lhs, struct artist *rhs) return string_compare_tokens(lhs->ar_tokens, rhs->ar_tokens); } +bool artist_match_token(struct artist *artist, const gchar *string) +{ + return string_match_token(string, artist->ar_tokens) || + string_match_token(string, artist->ar_alts); +} #ifdef CONFIG_TESTING const struct db_ops *test_artist_ops() { return &artist_ops; } #endif /* CONFIG_TESTING */ diff --git a/include/core/tags/artist.h b/include/core/tags/artist.h index e3c84689..ea754482 100644 --- a/include/core/tags/artist.h +++ b/include/core/tags/artist.h @@ -49,6 +49,9 @@ struct artist *artist_get(const unsigned int); /* Called to compare two artist tags. */ int artist_compare(struct artist *, struct artist *); +/* Called to check if an artist has a token that matches the given string. */ +bool artist_match_token(struct artist *artist, const gchar *); + #ifdef CONFIG_TESTING const struct db_ops *test_artist_ops(); #endif /* CONFIG_TESTING */ diff --git a/tests/core/tags/artist.c b/tests/core/tags/artist.c index ac28f2ad..c30035f6 100644 --- a/tests/core/tags/artist.c +++ b/tests/core/tags/artist.c @@ -34,7 +34,11 @@ static void test_artist() struct file f; artist = ARTIST(artist_ops->dbe_alloc("Koji Kondo")); + test_verify_koji(artist); + test_equal(artist_match_token(artist, "koji"), (bool)true); + test_equal(artist_match_token(artist, "kondo"), (bool)true); + test_equal(artist_match_token(artist, "hajime"), (bool)false); file_init(&f, "artist_tag", 0, 0); file_open(&f, OPEN_WRITE);