Media Sense queries

Document created by cdnadmin on Jan 25, 2014
Version 1Show Document
  • View in full screen mode
This document was generated from CDN thread

Created by: Matthew Hampton on 09-10-2013 01:28:35 PM
I have a quick question about Media Sense queries
How would I do a getSessions request for any sessions that do not have a particular tag or do not have any tag defined at all?
The high level view is that I want to process all of the sessions on the Media Sense server and set a tag for any session that I have already processed.
Then I want to be able to query the server for any sessions that I have not processed.

Subject: RE: Media Sense queries
Replied by: Jeffrey Wolfeld on 09-10-2013 08:03:41 PM
There is in fact a way to specify "NOT" - you can use a fieldOperator of "!equals" or "!between", etc.  However, it won't do what you need because tags are an array.  If you search for tagName !equal "processed", you'll get all sessions which contain at least one tag that is anything other than "processed".  That's not exactly what you had in mind.

I would suggest that you qualify your use of "processed" tags by timestamp.  You could search for recordings that have a sessionStartDate > X.  When you get them, process only those which have a sessionState of CLOSED_NORMAL and do not contain a "processed" tag.  Then insert the "processed" tag as soon as each one is completed.  When you have finished processing those, find the earliest session in that list which has a sessionState of ACTIVE, and set X to its sessionStartDate.  If there are none, then set X to the sessionStartDate of the latest session and add its duration.  If there were no sessions returned at all, then set X to the current time. Then rinse and repeat.

You will end up getting some sessions more than once, but you will not re-process them because you've added a "processed" tag to them already.  You'll also get ACTIVE sessions repeatedly until they become CLOSED_NORMAL.  And if there are any CLOSED_ERROR sessions, this algorithm will skip over them. (You will however receive them, so you could log them if you'd like.)

Please let us know if this solves the problem.

Jeff Wolfeld