Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    119

    Question: searching for tracks

    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:

    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} });
        }
    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).

    Any suggestion on how to do this - preferably in a single query (with a join?) using the API - would be much appreciated.

    Thanks,
    Roland

  2. #2
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    119
    Quote Originally Posted by Roland0 View Post
    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:

    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} });
        }
    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).

    Any suggestion on how to do this - preferably in a single query (with a join?) using the API - would be much appreciated.

    Thanks,
    Roland
    To partly answer my own question, it seems to work correctly like this:
    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} });
        }
    Still hope somebody can suggest a single-query solution...

    Roland

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •