Page 1 of 2

Search functionality explained

PostPosted: Mon Aug 02, 2010 11:32 pm
by zoster
Here's how the Search functionality works:

The individual plugins have to support Search. To do this you have to include a "_pluginSearch" function (see Shoutcast for an example).
Since the WDTV always sends a search query with the ContainerID "0" (the root menu) we don't really know where the user currently is. To work around this everytime the user starts a plugin its name is stored in a /tmp file. That plugin name is read upon a Search action and its _pluginSearch function is called.

The _pluginSearch function receives the full SearchCriteria string which usually looks like this:

Code: Select all
(upnp:class derivedfrom "object.item.videoItem") and dc:title contains "<The Search Term you entered>"


The _pluginSearch function is then supposed to return an array of media items just like the _pluginMain function.

Re: Search functionality explained

PostPosted: Sat Dec 18, 2010 11:55 am
by sombragris
Do you know if there is any chance to add new criteria? For example changing "title" to "Artist" in order to allow diferent searches to be conducted.

Re: Search functionality explained

PostPosted: Sun Dec 19, 2010 2:05 pm
by zoster
The music and pictures search has some additional attributes but they are all hardwired. What you could do is to come up with some sort of tag system like "a: <search term>" to search for artists. The parsing would be up to your search implementation.

Re: Search functionality explained

PostPosted: Mon Dec 20, 2010 3:43 am
by sombragris
Thanks zoster.

I think I'll use the "genre" to make expanded searches as it seems the most useless search on the web (and it could easily be implemented menu driven).

After reading your post I've made some tests, and I'll leave here the strings I've found for the _pluginSearch method for feedback:

By Title
Code: Select all
(upnp:class derivedfrom "object.item.audioItem.musicTrack") and dc:title contains "<The Search Term you entered>"


By Album
Code: Select all
(upnp:class derivedfrom "object.item.audioItem.musicTrack") and upnp:album contains "<The Search Term you entered>"


By Genre
Code: Select all
(upnp:class derivedfrom "object.item.audioItem.musicTrack") and upnp:genre contains "<The Search Term you entered>"


Please note, if the search is conducted through the music menu entry then the upnp:class is derived from "object.item.audioItem.musicTrack" if it was conducted through the video menu entry then the upnp:class is derived from "object.item.videoItem"

Re: Search functionality explained

PostPosted: Tue Mar 22, 2011 4:11 pm
by avkiev
How to execute (emulate... force...) "Search" ?
Can I in my plugin create some folder (or item) with name "Run Search" with such property: pressing Enter on it - equivalent to pressing "Search" button on remote ?

Re: Search functionality explained

PostPosted: Wed Mar 23, 2011 2:22 am
by mad_ady
@avkiev: There are 2 ways of doing it (assuming you don't want to test it by pressing search on the remote):

1. Use a web browser and navigate to http://&lt;your.wdtv.ip&gt;/umsp/umsp-test.php. Navigate to your plugin and if search is implemented you'll see a search box on your page and you can test the search functionality really easily
2. You can implement an item that when called would pass a special argument to your UMSP script (something like doSearch=xxx). Then, on the server side you can test for this and call your search function. But beware - you can't ask for user text in this step, since the OSD will not display a keyboard.

Hope this helps.

Re: Search functionality explained

PostPosted: Wed Mar 23, 2011 3:04 am
by avkiev
mad_ady wrote:if search is implemented you'll see a search box on your page

I have Search in my plugin. I want too have item with functionality "Search"

mad_ady wrote:But beware - you can't ask for user text

That is my question. How to force User Input Dialog without pressing Search button ?

Re: Search functionality explained

PostPosted: Wed Mar 23, 2011 3:46 am
by avkiev
The solution is: exec("echo E > /tmp/ir_injection");
E - it is Search
Can't try it now, but I hope it''ll works

Re: Search functionality explained

PostPosted: Wed Mar 23, 2011 4:45 am
by mad_ady
:)) Clever. You might need to run it through sudo, since apache is a different user and might not have the necessary privileges.

Question - why do you want to do that? What's wrong with the search button?

Re: Search functionality explained

PostPosted: Wed Mar 23, 2011 4:57 am
by avkiev
mad_ady wrote:Question - why do you want to do that? What's wrong with the search button?

Because Search is invisible.
Many users even don't know that some plugins has a Search function