INTERACT FORUM

More => Old Versions => JRiver Media Center 19 for Windows => Topic started by: connersw on January 15, 2014, 08:22:24 am

Title: Help With An Expression (Artist Letters)
Post by: connersw on January 15, 2014, 08:22:24 am
I've been using this expression to group by Artist Letters (thanks Mrc):

Code: [Select]
Regex([Artist], /#^(?:(?:the|an|a) +)?(.)#/,-1)if(Compare(1[R1], >=, 10), 0 - 9, [R1])
It's been working great, but I've started to use the list ability of the Artist field more and discovered a problem.  If there are multiple artists, it only uses the first letter of the first artist. 

For example: The All Star Band; The Levon Helm Band; My Morning Jacket
The All Star Band, The Levon Helm Band, and My Morning Jacket will all appear under the letter A. 

I would like each one to be placed under their own letter (ie A, L, and M).  Is that possible?



Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 15, 2014, 12:58:49 pm
Only to a limited extent.

The problem: MC doesn't have a list-iterator, so you can't grab the first letters of each item in the list generally.

With a more complex regex, that essentially replicates the current pattern and adds more optional cases following a semicolon, you could grab up to the first 9 (MC also limits the number of captures to 9, which I think was a limitation of the previous Microsoft TR1 regular expression library).  Of course, more conditional If's will be required too.

If your artists don't change that much, you could use an external script (hint: pscriptor) to populate another field with the results you want, and use that fields instead of Artists.
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 15, 2014, 03:09:44 pm
I doubt I would ever have more than 9 Artists in the Field.  I'd prefer to use an expression rather than an external script since it is automatic.  I would need to remember to run the scriplet every time I imported an Album in order to populate the new Field. 
Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 15, 2014, 06:00:40 pm
Why don't you do it this way, which is as extensible as you want to copy/paste:

Regex([Artist], /#^(?:(?:the|an|a) +)?(.)#/,-1)if(Compare(1[R1], >=, 10), 0 - 9, [R1])/
ifelse(compare(listcount([Artist]), >, 1),
;Regex(listitem([Artist], 1), /#^(?:(?:the|an|a) +)?(.)#/,-1)if(Compare(1[R1], >=, 10), 0 - 9, [R1]))/
ifelse(compare(listcount([Artist]), >, 2),
;Regex(listitem([Artist], 2), /#^(?:(?:the|an|a) +)?(.)#/,-1)if(Compare(1[R1], >=, 10), 0 - 9, [R1]))/
&datatype=[list]

Copy and paste a colored section and change the bold indexes accordingly.  1 is the second list item, 2 is the third, etc.
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 16, 2014, 08:28:26 am
Almost there, but not quite.  That places all of them in each letter (ie A has The All Star Band, The Levon Helm Band, and My Morning Jacket, L has The All Star Band, The Levon Helm Band, and My Morning Jacket , and M has The All Star Band, The Levon Helm Band, and My Morning Jacket).
Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 16, 2014, 11:10:11 am
if you have a track that has three artists, The All Star Band, The Levon Helm Band, and My Morning Jacket, which single grouping should it go under?  It contains three artists.

This is better suited to Panes or Categories where you can create a hierarchy, and you select based on the letter, and are presented with only the item that matched that letter.
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 16, 2014, 12:19:16 pm
It should go under all three, but only the Artist for that grouping should be shown.

Example:
A -> The All Star Band -> Track 27
L -> The Levon Helm Band -> Track 27
M -> My Morning Jacket -> Track 27

Right now it shows:
A -> The All Star Band -> Track 27
       The Levon Helm Band -> Track 27
       My Morning Jacket -> Track 27
L -> The All Star Band -> Track 27
       The Levon Helm Band -> Track 27
       My Morning Jacket -> Track 27
M -> The All Star Band -> Track 27
       The Levon Helm Band -> Track 27
       My Morning Jacket -> Track 27

This is better suited to Panes or Categories where you can create a hierarchy, and you select based on the letter, and are presented with only the item that matched that letter.

That is what I'm trying to do.
Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 16, 2014, 12:21:43 pm
I'm confused.  Are we talking about Group By?  If not, where?
Title: Re: Help With An Expression (Artist Letters)
Post by: glynor on January 16, 2014, 12:24:53 pm
I don't think he knows about the Category Grouping feature...

I'm on my phone right now, so I can't easily explain.
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 16, 2014, 12:38:34 pm
I'm aware of the Category Grouping feature, and it does not do it properly either.  It automatically groups by Album and doesn't break out the Artists. 
Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 16, 2014, 12:38:57 pm
Try this instead:

ifelse(compare(listcount([Artist]), >, 0),
    Regex(listitem([Artist], 0), /#^((?:(?:the|an|a) +)?(.).*)#/,-1)if(Compare(1[R2], >=, 10), 0 - 9, [R2])\[R1])/
ifelse(compare(listcount([Artist]), >, 1),
   ;Regex(listitem([Artist], 1), /#^((?:(?:the|an|a) +)?(.).*)#/,-1)if(Compare(1[R2], >=, 10), 0 - 9, [R2])\[R1])/
ifelse(compare(listcount([Artist]), >, 2),
   ;Regex(listitem([Artist], 2), /#^((?:(?:the|an|a) +)?(.).*)#/,-1)if(Compare(1[R2], >=, 10), 0 - 9, [R2])\[R1])/
&datatype=[list]
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 16, 2014, 12:41:50 pm
BAM!  That's it.  Thank you for you patience with me MrC. 
Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 16, 2014, 12:47:41 pm
No sweat.  I got confused by the term "group by" in your original post.

I captured the entire Artist name in the RE (as [R1]) to show in the nested level.  If you want the artist sans articles, use:

   /#^(?:(?:the|an|a) +)?((.).*)#/

as the RE.
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 16, 2014, 12:48:31 pm
Ahh....I just figured out why Category Grouping does that and possibly what Glynor was going to explain.

I need to double the Categories.  So:

Artist (Grouping Size 1)
Artist
Album  

Thanks for bearing with me.  
Title: Re: Help With An Expression (Artist Letters)
Post by: glynor on January 16, 2014, 01:02:45 pm
Yep, that's it.

(http://glynor.com/img/screenshots/MC19/MC19-Category_Grouping_Example.png)
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 17, 2014, 10:06:58 am
Try this instead:

ifelse(compare(listcount([Artist]), >, 0),
    Regex(listitem([Artist], 0), /#^((?:(?:the|an|a) +)?(.).*)#/,-1)if(Compare(1[R2], >=, 10), 0 - 9, [R2])\[R1])/
ifelse(compare(listcount([Artist]), >, 1),
   ;Regex(listitem([Artist], 1), /#^((?:(?:the|an|a) +)?(.).*)#/,-1)if(Compare(1[R2], >=, 10), 0 - 9, [R2])\[R1])/
ifelse(compare(listcount([Artist]), >, 2),
   ;Regex(listitem([Artist], 2), /#^((?:(?:the|an|a) +)?(.).*)#/,-1)if(Compare(1[R2], >=, 10), 0 - 9, [R2])\[R1])/
&datatype=[list]

So this is working perfectly, and it doesn't appear to be limited to the first 9.  I copy and pasted it out and tested it with up to 15-Artists, and it worked.  I prefer it to the Category Grouping feature since it places all numbers in 0-9 instead of individual groups for 1, 2, 3, etc.

However, it places special characters (!, $, &, etc) in their own individual grouping.  Category Grouping puts them all in a group called "Others."  I would like to do the same thing except have them under * so they are first in the alphabetical listing rather than after O.

Could I trouble you for assistance one more time?
Title: Re: Help With An Expression (Artist Letters)
Post by: MrC on January 17, 2014, 10:36:10 am
Replace [R2] with FormatRange([R2],1,1).  This won't place them under *, but will use FormatRange's "(Others)" and its special sorting.  You can of course post-replace that by replacing "(Others)" with whatever you want.
Title: Re: Help With An Expression (Artist Letters)
Post by: connersw on January 17, 2014, 11:09:42 am
Perfect--many thanks.  (Others) actually works nicely since it will come first alphabetically as opposed to Others in Category Grouping. 
Title: Re: Help With An Expression (Artist Letters)
Post by: MGD_King on January 26, 2014, 08:06:49 am
This works like a charm while using Gizmo! It makes locating an artist so much easier now!! Thanks MrC!