INTERACT FORUM

Please login or register.

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

Author Topic: Feature request, new function to count related items  (Read 3223 times)

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Feature request, new function to count related items
« on: September 23, 2019, 11:34:25 am »

I'd really love a way to get a count of related items in my library, I am thinking something like this.

ItemCount()

ItemCount(Series)   returns the number of files for a given series (e.g. so this would be the number of episodes)
ItemCount(Series,Season=1)   returns the number of files for a given series for season 1
ItemCount(Series,Season=1,3)   returns the number of files for a given series for seasons 1 and 3
ItemCount(Series,Season=1-5)   returns the number of files for a given series for seasons 1 through 5
ItemCount(Artist) returns the number of files for a given Artist
ItemCount(AlbumKey())   returns the number of tracks for a given "album" (as defined by the AlbumKey() function)
ItemCount(AlbumKey(),Disc #)   returns the number of discs for a given album
Logged

BigCat

  • Regular Member
  • World Citizen
  • ***
  • Posts: 212
  • Believe...
Re: Feature request, new function to count related items
« Reply #1 on: September 24, 2019, 12:14:41 am »

That sounds pretty cool. If I understand you, I could use that. I wish in the library that in the categories like Genre, Artist, etc JRiver would tell you how many files are in each one without having to click on each one.

Like:

Flamenco (800)
Folk (4667)
etc...
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Feature request, new function to count related items
« Reply #2 on: September 24, 2019, 02:58:26 am »

Yes, very practical, love this feature  ;)
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Feature request, new function to count related items
« Reply #3 on: September 24, 2019, 05:03:52 am »

there is Groupcount()

it's not quite what you are talking about but it can do a few things

https://wiki.jriver.com/index.php/Grouping_Functions#GroupCount.28.E2.80.A6.29_2
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Feature request, new function to count related items
« Reply #4 on: September 24, 2019, 09:00:28 am »

there is Groupcount()

it's not quite what you are talking about but it can do a few things

https://wiki.jriver.com/index.php/Grouping_Functions#GroupCount.28.E2.80.A6.29_2

Indeed... Stuff like that...


Expression pane, expression to group by: [Genre,1] <font color="0xaeafce">(groupcount())<//font>

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #5 on: September 24, 2019, 09:00:59 am »

ferday is right on that GroupCount(...) already exists and does a lot.

If there's another angle we should consider with that function, just let us know.

Thanks.
Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new function to count related items
« Reply #6 on: September 24, 2019, 10:23:53 am »

I am well aware of Groupcount() and Groupsummary().  These work on a more global basis.

If I put in Groupcount(series) it will tell me how many unique values I have in the Series field.

As an example, lets say I have two series, Series A that has two seasons, each with ten episodes.  And Series B that has 4 seasons, each with twelve episodes.

With my proposed new function if I put in ItemCount(series).

Series A would return 20
Series B would return 48

If I were to enter ItemCount(season) 

Series A would return 2
Series B would return 4

If I were to enter ItemCount(Series,Season=1,3)   

Series A would return 10 (as it doesn't have a third season)
Series B would return 24 (season 1 and season 3 both have 12 episodes, hence 24)

Now lets say I have a 10 disc box set for a band. Each disc has 10 tracks.

If I enter ItemCount(AlbumKey(),Disc #)   it would return 10
If I enter ItemCount(AlbumKey(),name) it would return 100
If I enter ItemCount(AlbumKey(),duration) it would return the length of the entire box set
If I enter ItemCount(AlbumKey(),duration,disc #=3) it would return the entire length of disc #3

And so on and so forth.  I think this would come in extremely handy.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10940
Re: Feature request, new function to count related items
« Reply #7 on: September 24, 2019, 10:52:58 am »

Expressions that work on the entire database can be extremely costly, which is where GroupCount comes in - it operates in the context of the current view, which is data thats already "hot", and thus easier to aggregate.
From what I can tell, GroupCount and GroupSummary should be able to fullfill the majority of these tasks already, so lets look at those.

And to be honest your function is not really well defined. It does what you want it to do, because you described it like that, but to actually be reasonable it would have had to have a far stricter syntax, and not "magically" do the right thing.

PS:
Season is a string field, ranges are not well-defined for strings.
Logged
~ nevcairiel
~ Author of LAV Filters

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new function to count related items
« Reply #8 on: September 24, 2019, 12:04:12 pm »

Quote
From what I can tell, GroupCount and GroupSummary should be able to fullfill the majority of these tasks already, so lets look at those.

If what I am trying to do can be done with GroupCount or GroupSummary, I'd be more than happy to use those.  I certainly can't figure out how to do so.  Here are some problems I would like to solve.

The ability to display how many episodes are in a specific TV series.
The ability to display how many episodes are in a specific season of a TV series
The ability to display how many episodes are in a specific range of seasons of a TV series
The ability to display how many tracks there are on an specific album
The ability to display how many discs make up a specific multi disc set
The ability to display the duration of an entire album
The ability to display how many albums I have from a specific artist
The ability to display how many songs I have from a specific artist

There are others, but this is a good start.  If I can do this with GroupCount or GroupSummary I'd love an education in how to do so.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #9 on: September 24, 2019, 12:46:37 pm »

I started playing with this idea:
The ability to display how many tracks there are on an specific album

But I just can't make it fast enough to be usable.

It needs to gather all the files in the database, then look through each one for a matching album value.

Even if I cache the "all files", the looking through all the files is still pretty slow.

So I'm not sure if we'll add this.

If you have some clever idea, please share.  Thanks.
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #10 on: September 24, 2019, 02:03:02 pm »

I'm thinking about caching the results and supporting expressions like AlbumKey().

Stay tuned :)
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #11 on: September 24, 2019, 02:12:02 pm »

I think it's working really well.

I just rebuild the cache every minute.

Then you say something like this to use an expression:
ItemCount(AlbumKey/(/))

And it just works perfect and gives you the count of files inside each album.

Thanks a lot for the idea :)
Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new function to count related items
« Reply #12 on: September 24, 2019, 03:00:57 pm »

Awesome! 

Can you replace AlbumKey with other values? 
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #13 on: September 24, 2019, 03:03:38 pm »

Awesome! 

Can you replace AlbumKey with other values?

It takes any expression.  You just need to remember to escape it since it's inside a function already.
Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new function to count related items
« Reply #14 on: September 24, 2019, 03:13:41 pm »

Thank you so much, this is going to be really useful.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4231
Re: Feature request, new function to count related items
« Reply #15 on: September 24, 2019, 03:36:46 pm »

I just rebuild the cache every minute.
what are you caching? why would you need to rebuild it every minute? if it's library data then is that largely static data (which is changed by specific events)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #16 on: September 24, 2019, 04:14:47 pm »

what are you caching? why would you need to rebuild it every minute? if it's library data then is that largely static data (which is changed by specific events)

If new files are imported or data changed.  It wasn't easy to hook MCC commands up so I just do it on a timer.
Logged
Matt Ashland, JRiver Media Center

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4231
Re: Feature request, new function to count related items
« Reply #17 on: September 24, 2019, 04:18:30 pm »

If new files are imported or data changed.  It wasn't easy to hook MCC commands up so I just do it on a timer.
it's a really cheap operation or it can tell if the library has changed so does no unnecessary work?
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Feature request, new function to count related items
« Reply #18 on: September 24, 2019, 06:53:15 pm »

It takes any expression.  You just need to remember to escape it since it's inside a function already.

It is my birthday tomorrow and I went out after work so I could be (definitely am) pretty dull, but... Could you explain this better?
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72443
  • Where did I put my teeth?
Re: Feature request, new function to count related items
« Reply #19 on: September 24, 2019, 06:54:04 pm »

Because whiskey   :P

Birthday Happy.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42376
  • Shoes gone again!
Re: Feature request, new function to count related items
« Reply #20 on: September 24, 2019, 07:03:26 pm »

It is my birthday tomorrow and I went out after work so I could be (definitely am) pretty dull, but... Could you explain this better?

You'll need more whiskey and to put a slash in front of brackets and parens.
Logged
Matt Ashland, JRiver Media Center

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Feature request, new function to count related items
« Reply #21 on: September 24, 2019, 08:17:01 pm »

You'll need more whiskey and to put a slash in front of brackets and parens.

 ;D

I knew what you were telling me to do. I didn't understand the why. But...

I must have sobered up somewhat because now I get it. ¯\_(ツ)_/¯

Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

BigCat

  • Regular Member
  • World Citizen
  • ***
  • Posts: 212
  • Believe...
Re: Feature request, new function to count related items
« Reply #22 on: September 24, 2019, 10:23:21 pm »

Marko, yes, that is what I wanted to do! Thanks! Had no idea that was there!

And happy birthday, glynor!
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Feature request, new function to count related items
« Reply #23 on: September 25, 2019, 02:49:33 am »

I mentioned this in another thread, but MC has a bug that returns incorrect results for GroupCount when used as thumbnail text in standard view.  It always works correctly in theater view.

GroupSummary is affected by a similar issue which I mentioned previously (GroupSummary numeric results get truncated in Standard view) making them less accurate.  GroupCount in standard view thumbnail text is just out and out broken, however.
Logged

BigCat

  • Regular Member
  • World Citizen
  • ***
  • Posts: 212
  • Believe...
Re: Feature request, new function to count related items
« Reply #24 on: September 25, 2019, 11:48:15 pm »

Whoops, I spoke too soon. I hope I am not hijacking this thread, but when I copied the settings Marko gave for, say, the genre pane, it does put a number after each individual genre name, but the number is always (1). I must have something not set right.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Feature request, new function to count related items
« Reply #25 on: September 26, 2019, 01:04:26 am »

BigCat, you probably followed the instructions correctly, but I think as written they contain a mistake.

What you actually need to do for your expression pane is this:
Expression to group by:  [Genre]
Expression to display: [Genre]  (GroupCount())

If you put GroupCount in Expression to Group by, it returns a 1.

I should point out, if you do GroupCount() then it is counting files/tracks.  You could instead do something like GroupCount(Album) and then it would count the albums in each genre, when used in this pane.  But you could also do something more elaborate:
[Genre]  (GroupCount(Album) Albums, GroupCount() Tracks)

-Will
Logged

BigCat

  • Regular Member
  • World Citizen
  • ***
  • Posts: 212
  • Believe...
Re: Feature request, new function to count related items
« Reply #26 on: September 26, 2019, 01:56:12 am »

Thanks wer, that seems to have done it!
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Feature request, new function to count related items
« Reply #27 on: September 27, 2019, 01:19:05 pm »

FYI, the bug affecting GroupCount and GroupSummary has been fixed in 25.0.106. 

Using these expressions in the "Expression to group by" field now returns proper results for the expression, but it does cause your view to group things in ways you might not be expecting, even though it's working correctly.  For this reason, you would usually want to only use it in the "Expression to display field".

If you use, for example, [Album] (GroupSummary(Rating)) in expression to group by, you would get something like this in the pane:
Let it Be (2)
Let it Be (3)
Let it Be (4)

if your 12-track Let it Be album had 5 songs rated 3 stars, 6 songs rated 4 stars, and 1 song rated 2 stars.  Each unique rating value (2, 3 or 4 stars) is counted as a separate group.
Logged
Pages: [1]   Go Up