INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: FieldQuery question and/or request  (Read 372 times)

Doof

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5908
  • Farm Animal Stupid
FieldQuery question and/or request
« on: September 24, 2021, 12:45:19 am »

FieldQuery takes a parameter that defines the scope of the query. Currently that scope is limited to either All files in the library or all files in the current view. I was wondering if it would be possible to add a some additional modes, one that allows you to narrow the search field down even further.

For example, it would be great if you could specify a scope to include only certain Media Types. If I'm searching for a list of Directors or Years from a bunch of Movies, then it doesn't make sense to query audio files for potential matches, for example.

Additionally, it would be nice if I could specify a search query that would be used to provide the pool for files to query for matches.

What I'm currently trying to accomplish is an expression that will return the series premiere year for a given tv episode. I've managed to do this with the following expression: FormatDate(ListMath(FieldQuery(Series, [Series], Date, 0, 1), 0), yyyy), which finds all files that have the same Series value as the current file, then returns all of the dates for those files, finds the smallest (oldest) date and returns just the year. I can then feed this into my TV renaming expression and include this year as part of the folder name, ie: \TV\Breaking Bad (2008)\Season 01\

It works, but it's slow. First of all, the Scope modifier doesn't appear to work as I understand it should from the docs. Although it says that mode 1 should limit the query to files within the current view, if I set an audio file's Series tag to the same value as a TV show, that audio file's Year value is included in the list and potentially tainting the results of the expression. Obviously I wouldn't tag an audio file with a Series value normally, but I tried it as a test using an Audio file (Black Sabbath - Iron Man) with a date (1971) earlier than the TV show (2019) I was testing with and now my expression returns the same results no matter which scope mode I choose, even though the audio file isn't in the same view as the TV Show episodes. In this instance the expression returns 1971 for all files in the view, even though it shows 2019 as it should when I remove the Series tag from the audio file. And again, switching scoping modes doesn't appear to be making any difference. Not sure if this is a bug or if I'm misunderstanding how it works.

Regardless, I don't want to use mode 1 as I really need my expression to search beyond files in the current view in order to return the value I'm looking for. But mode 0 is much too broad to use efficiently. Wouldn't it be far more efficient for MC to limit the search query to files of the same Media Type, or even Media Sub Type? I'm sure there are usecases where mixed types makes sense but I would think it's far more likely that a query is intended to run against files all of the same general Sub Type than they are to search across all Sub Types, let alone all file types. So can I propose two (three if I'm greedy) additional scoping modes?

2: Limit to same Media Type
3: Limit to same Media Sub Type
4: Custom search query (not sure how you'd write this out in an expression)

So then to continue my query example from above, it could become FormatDate(ListMath(FieldQuery(Series, [Series], Date, 0, 3), 0), yyyy) which would perform the same query as above, but allow me to expand the search to files not in the current view, but still limit it to files of the same Media Sub Type, meaning only other TV Shows.

Maybe I'm wrong in my assumption about how others are using this function, or maybe there's a far more efficient way to do what I'm trying to do (in which case I'd happily accept any suggestions)? Thoughts?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42378
  • Shoes gone again!
Re: FieldQuery question and/or request
« Reply #1 on: September 24, 2021, 08:31:55 am »

So basically add a Scope "2" that matches the media type?

I think I can work that in today. 

I'm not sure how to ever refresh the list of files (we need to cache for performance), so you might need to restart if you import more files you want seen.

Thanks for the suggestion.
Logged
Matt Ashland, JRiver Media Center

Doof

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5908
  • Farm Animal Stupid
Re: FieldQuery question and/or request
« Reply #2 on: September 24, 2021, 11:29:36 am »

Thanks! That would certainly reduce the number of files MC has to search through!

For me alone that would mean a difference of only searching through ~9k files instead of ~114k so this should make some massive improvements for this expression.
Logged
Pages: [1]   Go Up