In a plugin, I am trying to seach for tracks by artist name and song title. Since I haven't found an obvious way to do this in one query, this was my next approach:
This somehow works, but not reliably: Quite a number of artists and songs are not found, although they are in the library (and can be found by searching in the web interface).Code:@contRS = Slim::Schema->rs('Contributor')->search( {'namesearch' => uc($artistname) }); if(@contRS) { @cont = (); foreach (@contRS) { push @cont, $_->get('id'); } @tracks = Slim::Schema->rs('Track')->search( {'titlesearch' => uc($songtitle), 'primary_artist' => { 'in' => \@cont} }); }
Any suggestion on how to do this - preferably in a single query (with a join?) using the API - would be much appreciated.
Thanks,
Roland
Results 1 to 2 of 2
Thread: Question: searching for tracks
-
2012-08-02, 13:24 #1Senior Member
- Join Date
- Aug 2012
- Location
- Austria
- Posts
- 119
Question: searching for tracks
-
2012-08-04, 08:58 #2Senior Member
- Join Date
- Aug 2012
- Location
- Austria
- Posts
- 119
To partly answer my own question, it seems to work correctly like this:
Still hope somebody can suggest a single-query solution...Code:@contRS = Slim::Schema->rs('Contributor')->search( {'namesearch' => Slim::Utils::Text::ignoreCaseArticles($artistname) }); if(@contRS) { @cont = (); foreach (@contRS) { push @cont, $_->get('id'); } @tracks = Slim::Schema->rs('Track')->search( {'titlesearch' => Slim::Utils::Text::ignoreCaseArticles($songtitle), 'primary_artist' => { 'in' => \@cont} }); }
Roland

Reply With Quote

