Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tip O' The Day : Searching for Media
#1
For the most part you get to media by browsing for it within CQC. But, sometimes you may want to search for a particular piece of media. As is always the case within CQC, in order to access a given piece of media, you need the appropriate media cookie. That cookie is an id for that piece of media, which is handed out by a media repository. You can pass that cookie to a media renderer, which will use it to go back to the repository and get the information it needs to play the media. And of course you can use that cookie to get metadata info from the repository as well.

All standard CQC media repository drivers support a standard backdoor command that it uses to expose media searching. It uses the standard backdoor method that lets you query a text value from a driver, which looks like:

Code:
If Devices::QueryDrvText(mon, qtype, qdata , outputvar)
   // A value was returned
EndIf

The parameters are:
  • Moniker. The driver to query from
  • Type. The type of data you want to get
  • Data. The specific value of this type you want to get
  • Variable. A variable to put the value into if one is returned

The middle two are arbitrary and defined by each driver. For this particular query, the values are:
  • CookieLookup. Indicates you want to do a cookie lookup
  • [searchstring] A string that defines what you want to find, the format of which is discussed next.

The search string has this format:

Code:
media type, cookie type, cat name[, title name, collection name, item name]

Everything after category name is optional, but you have to pass enough for the type of cookie you indicate you are searching for. So up to cat name if you want a category, up to title name if you want a title, and so forth. The values actually have to be quoted since it's a quoted comma list.

For most purposes you would do something like this:

Code:
"Movie", "Title", "All Movies", "Batman Begins"

So you want a movie, you want to get a title cookie, there has to be a category though it's not used if you are not searching for a category, so just use All Movies which is always valid, and then the title to search for. Or of course it could be for music, in which case more like:

Code:
"Music", "Title", "All Music", "Let it Be"


If the requested cookie is found, then you can use it anywhere else you would use such a cookie. You can pass it to a renderer to be queued up, or use it in any action command that takes that kind of cookie. If you want a particular collection if a multi-collection title set, just add a 1 based number to it. The cookie is just a string of comma separated values, so add a comma and the collection number you want. So, if you get back a title cookie in LVar:SearchRes, you could do:

LocalVars::Append(LVar:SearchRes, ,1)

There's not an empty parameter there, there are just two parameters, the second of which is ,1. It's awkward showing actions like this if the parameter values have commas in them, since it's ambiguous where each parameter starts. That's why CQC tends to show them split out into separate lines.

Collections are only generally useful for music, but if it's a multi-disc title set (some repos provide that type of title level info), you can get to a specific disc in the same sort of way.


Anyway, give that a try. One way you might want to use it is for voice selection of media. So you can let the user request a title to play, and use the above to try to find it. It can be tricky because it has to be an exact match and the Echo doesn't always get it right, and punctuation could be an issue.

At some point here we'll add a smarter type of search, and add some specific action commands for that sort of thing, which will talk to the local client service instead of the media repository. That would be far more efficient. That's what the search commands on the Cover Art Browser does, for instance.
Dean Roddey
Explorans limites defectum
Reply
#2
What happens if it doesn't find the requested item? Blank result?
Reply
#3
The return will be false. So you can use it in an If statement.

Code:
If (Devices::QueryDrvText(...))
EndIf
Dean Roddey
Explorans limites defectum
Reply
#4
OK, slight amendment. The search criteria values are a quoted comma list, so the values have to be quoted and comma separated. The first post was updated accordingly. Sorry about that.
Dean Roddey
Explorans limites defectum
Reply
#5
So how does one retrieve a single song, rather than an album? Using "Title" still only retrieves an album!
Thanks
Reply
#6
You have to provide the other values in the list, the collection name and item name, and indicate you want an item cookie.

There's currently no way to just search for an item name, though that would obviously be useful. I'll put that on the list.
Dean Roddey
Explorans limites defectum
Reply
#7
Dean,
What would I have to do to play a playlist (.m3u). Also, can it be anywhere or does it need to be in a particular folder?
Thanks
Reply
#8
Are you using the file tag repo? They are only used by that. If so, put them in a directory under the top level that you point the repo driver at. At the top level would be fine, or maybe make a 'Playlists' directory and put them in there.

You would be better off using the other type of file, the .m3u8 and making sure you save the file in UTF-8 format. That way, you don't have to worry about non-English or non-Latin1 characters in the title names.
Dean Roddey
Explorans limites defectum
Reply
#9
Dean Roddey Wrote:Are you using the file tag repo? They are only used by that. If so, put them in a directory under the top level that you point the repo driver at. At the top level would be fine, or maybe make a 'Playlists' directory and put them in there.

You would be better off using the other type of file, the .m3u8 and making sure you save the file in UTF-8 format. That way, you don't have to worry about non-English or non-Latin1 characters in the title names.

Thanks Dean,
Using tag repo.
Will follow your advice on the .m3u8. What about the format of the play command. Currently to get something to play, I have to reference the Album name. Can I play the playlist. It seems to be an item.
Reply
#10
Currently this not working;
If
System::Equals
P1=%(LVar:CQCActParm_1)
P2=CQCRunWithIntent
P3=No Case

If
System::Equals
P1=%(LVar:CQCActParm_2)
P2=playlist
P3=No Case

LocalVars::SetVariable
P1=LVar:temp1
P2=%(LVar:CQCActParm_3)

LocalVars::SetVariable
P1=LVar:SearchString
P2="Music", "Title", "All Music", "%(LVar:CQCActParm_3)"

If
Devices::QueryDrvText
P1=FTB3
P2=CookieLookup
P3="Music", "Title", "All Music", "%(LVar:CQCActParm_3)"
P4=LVar:OutputVar

Devices::FieldWrite
P1=SonosV2Renderer.MREND#EnqueueMedia
P2=%(LVar:OutputVar)
P3=True

GlobalVars::SetVariable
P1=GVar:EchoReply
P2=Playlist %(LVar:temp1) now playing

Else

GlobalVars::SetVariable
P1=GVar:EchoReply
P2=Playlist %(LVar:temp1) not found

End

End

End
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Media Repository simplextech 10 3,718 01-09-2020, 07:19 PM
Last Post: simplextech
  Media playing from Event simplextech 11 3,846 01-07-2020, 06:09 PM
Last Post: simplextech
  SubSonic Media Server API Support? gReatAutomation 4 2,388 06-16-2019, 02:45 PM
Last Post: gReatAutomation
  Updated to V2 media drivers tom 8 4,201 11-26-2017, 11:10 AM
Last Post: Dean Roddey
  Logitech Media Server/squeezebox driver freezes Admin interface lleo 7 6,183 10-21-2017, 11:11 AM
Last Post: Dean Roddey
  SOLVED: Media System Config Issue agarden 3 3,599 04-29-2017, 07:25 AM
Last Post: agarden
  Searching the v5 documentation? dlmorgan999 1 1,844 11-01-2016, 08:20 PM
Last Post: Dean Roddey
  TV Shows and Media Repos potts.mike 6 3,246 06-19-2016, 04:30 AM
Last Post: wuench
  media repository help zane 5 3,372 04-29-2016, 10:33 AM
Last Post: zane
  New Plex Media Support Dean Roddey 96 28,223 10-04-2015, 09:11 PM
Last Post: NightLight

Forum Jump:


Users browsing this thread: 1 Guest(s)