INTERACT FORUM

Please login or register.

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

Author Topic: FormatDuration Pane  (Read 2575 times)

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
FormatDuration Pane
« on: April 24, 2014, 02:54:09 am »

I'm trying to make a pane for videos with formatduration

Ascending sorting is completely awry, is this a bug? MC Doesn't seem to know the difference between minutes and hours. Is there an easy way to force output in the meantime so all durations output to 7 decimal places, so sorting works ok? I thought about using length and math calculate the missing places, but at is still early in the morning here and it will include 0's and :'s, I'm a little stuck.

like 0:01:22 as opposed to 1:22?

I'm trying to make it as simple as possible because it's for use in a pane that uses global expressions to include videos that belong to multiple groups.

My expressions for file display
[=save(0,v_count_listitem([Group ID],0,;))1]=1
[=save(0,v_count_listitem([Group ID],1,;))1]=1
[=save(0,v_count_listitem([Group ID],2,;))1]=1
[=save(0,v_count_listitem([Group ID],3,;))1]=1

[=ifelse(!isempty(listitem([Group ID],0,;)),save(math([duration,0]+load(v_count_listitem([Group ID],0,;))),v_count_listitem([Group ID],0,;)))1]=1
[=ifelse(!isempty(listitem([Group ID],1,;)),save(math([duration,0]+load(v_count_listitem([Group ID],1,;))),v_count_listitem([Group ID],1,;)))1]=1
[=ifelse(!isempty(listitem([Group ID],2,;)),save(math([duration,0]+load(v_count_listitem([Group ID],2,;))),v_count_listitem([Group ID],2,;)))1]=1
[=ifelse(!isempty(listitem([Group ID],3,;)),save(math([duration,0]+load(v_count_listitem([Group ID],3,;))),v_count_listitem([Group ID],3,;)))1]=1

My Pane expression
ifelse(regex([Group ID];, /#(?:([^;]+);\s?)(?:([^;]+);\s?)?(?:([^;]+);\s?)?(?:([^;]+);\s?)?#/),
   delimit([R1], ,  FormatDuration(load(v_count_[R1])):/ );
   delimit([R2], ,  FormatDuration(load(v_count_[R2])):/ );
   delimit([R3], ,  FormatDuration(load(v_count_[R3])):/ );
   delimit([R4], ,  FormatDuration(load(v_count_[R4])):/ );
)&datatype=[list]
Thanks

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: FormatDuration Pane
« Reply #1 on: April 24, 2014, 03:03:07 am »

If no one responds by tomorrow. I'll take a look.
Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: FormatDuration Pane
« Reply #2 on: April 24, 2014, 03:06:33 am »

Thanks MrC appreciate it :)

I'll keep trying in the meantime, will post back if I find a solution.
Logged

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: FormatDuration Pane
« Reply #3 on: April 24, 2014, 03:24:14 am »

Think I've come up with a rough solution, you probably know of a more elegant way.
if(compare(length([Duration]), <, 7),mid(0:00:00, 0, Math(7-length([Duration])))[Duration],[Duration])

Now just need to try and include it in my expression now :)


Edit
Got it included now, a bit messy but it seems to be working
ifelse(regex([Group ID];, /#(?:([^;]+);\s?)(?:([^;]+);\s?)?(?:([^;]+);\s?)?(?:([^;]+);\s?)?#/),
   delimit([R1], ,  /
if(compare(length(FormatDuration(load(v_count_[R1]))), <, 7),mid(0:00:00, 0, Math(7-length(FormatDuration(load(v_count_[R1])))))FormatDuration(load(v_count_[R1])),FormatDuration(load(v_count_[R1]))):/ );
   delimit([R2], ,  /
if(compare(length(FormatDuration(load(v_count_[R2]))), <, 7),mid(0:00:00, 0, Math(7-length(FormatDuration(load(v_count_[R2])))))FormatDuration(load(v_count_[R2])),FormatDuration(load(v_count_[R2]))):/ );
   delimit([R3], ,  /
if(compare(length(FormatDuration(load(v_count_[R3]))), <, 7),mid(0:00:00, 0, Math(7-length(FormatDuration(load(v_count_[R3])))))FormatDuration(load(v_count_[R3])),FormatDuration(load(v_count_[R3]))):/ );
   delimit([R4], ,  /
if(compare(length(FormatDuration(load(v_count_[R4]))), <, 7),mid(0:00:00, 0, Math(7-length(FormatDuration(load(v_count_[R4])))))FormatDuration(load(v_count_[R4])),FormatDuration(load(v_count_[R4]))):/ );
)&datatype=[list]

Edit
Something isn't quite working right with what I came up with, it is adding extra groupings to the pane like 4:00:00.... where the files belong to multiple groupings. Once an entry like this is selected the total sum of the duration of files don't reflect the number in the pane.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: FormatDuration Pane
« Reply #4 on: April 24, 2014, 12:05:33 pm »

Note: you do have an extraneous semicolon:

   ... length(FormatDuration(load(v_count_[R4])))))FormatDuration(load(v_count_[R4])),FormatDuration(load(v_count_[R4]))):/ ); ...


Global variables set in rules for file display, and then used in panes calculations, and then pane values selected for filtering don't always behave well.

There is some explanation in a beta thread, where I reported:

I think I'm seeing a bug when selecting a value in a pane column, when the column values are derived from global variables.  First, here's a link to the movie that shows the problem:

    https://www.dropbox.com/s/kv9gmv2885mddya/possible%20bug.mp4

Here is how the view is created:

Set rules for file display below.  These just initialize two variables to 0, and then later increment either of the variables depending upon the value of the field [Custom]:

[=save(0,exc_[Artist])1]=1 [=save(0,inc_[Artist])1]=1 [=if(isequal([Custom],EXCLUDE), save(math(1 + load(exc_[Artist])),exc_[Artist]), save(math(1 + load(inc_[Artist])),inc_[Artist]))1]=1

The library has two calculated user fields which are defined as:

   _v_exc:    load(exc_[Artist])
   _v_inc:     load(inc_[Artist])

The movie shows these in the file list column.  It is clear that clicking on them selects the files that produced the cell value.  So this works.

The movie also shows that the view has a calculated field - this pane column's expression demonstrates the problem:

   math( [_v_exc] & [_v_inc] )

The calculated values are correct - the pane shows both values 0 and 1, as expected, since some of the 90 files have the EXCLUDE keyword in Custom.

However, notice how clicking on either value produces the wrong file list - its all files or no files.

and Matt replied:

MrC, you're in uncharted territory.

When you pick '1' in your AND expression pane, it's effectively saying "show files that match these two searches":
Code: [Select]
[=save(0,exc_[Artist])1]=1 [=save(0,inc_[Artist])1]=1 [=if(isequal([Custom],EXCLUDE), save(math(1 + load(exc_[Artist])),exc_[Artist]), save(math(1 + load(inc_[Artist])),inc_[Artist]))1]=1 [Media Type]=[Video]

[=math( [_v_exc] & [_v_inc] )]=[1]

The search compiler combines searches, sorts token ordering, etc. to help performance.  It's not really designed have dependencies that require a deterministic evaluation ordering, which only arise when there are save and load calls.

It's possible we could make the compiler smarter for cases like this.

However, I'm not thrilled with packing up the global variable store like this as it seems like a complex solution.  Is there some construct that would allow the same functionality without using variables like that?  Feel free to start a thread.

Thanks.

Some other explanations and references:

   http://yabb.jriver.com/interact/index.php?topic=77826.msg528624#msg528624
   http://yabb.jriver.com/interact/index.php?topic=77826.msg557444#msg557444

There might be some bug that could be fixed, but a) this usage of global variables is something very obtuse, and b) there's nobody at JRiver currently who is likely to look at this.
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: FormatDuration Pane
« Reply #5 on: April 24, 2014, 12:42:45 pm »

Also, here's a technique that gets rid of the FormatNumber(), pads better, and gets ride of the limited Regex() so you can more easily extend this when you have more items in Group ID:
Code: [Select]
ifelse(compare(listcount([Group ID]),>,0),
   padnumber(math(v=load(v_count_listitem([Group ID], 0)); trunc(v / 3660,0)),2):/
   padnumber(math(v=load(v_count_listitem([Group ID], 0)); trunc(v / 60,0) % 60),2):/
   padnumber(math(v=load(v_count_listitem([Group ID], 0)); trunc(v % 60,0)),2)/
) listitem([Group ID], 0);/
ifelse(compare(listcount([Group ID]),>,1),
   padnumber(math(v=load(v_count_listitem([Group ID], 1)); trunc(v / 3660,0)),2):/
   padnumber(math(v=load(v_count_listitem([Group ID], 1)); trunc(v / 60,0) % 60),2):/
   padnumber(math(v=load(v_count_listitem([Group ID], 1)); trunc(v % 60,0)),2)/
) listitem([Group ID], 1)/
&datatype=[list]

This only does the first two items in the Group ID; I'll leave the remainder as an exercise for you.  :-)
Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: FormatDuration Pane
« Reply #6 on: April 25, 2014, 05:11:10 am »

Excellent that's much nicer than what I used ;D Seriously don't know how you do this stuff, so quick and seemingly so effortlessly  ?

Those boards are off limits to me, would you mind making me beta, so I could take a peek?

Quote
there's nobody at JRiver currently who is likely to look at this.
I'm just glad it can be worked around as it will be useful to me

Thanks
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: FormatDuration Pane
« Reply #7 on: April 25, 2014, 11:56:15 am »

I think allowing beta-board access is something officially reserved for JimH, Matt, etc.

I've copied the text from the beta threads above, so go ahead and have a look.

I'm glad you like the new, more extensible technique.  :-)
Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: FormatDuration Pane
« Reply #8 on: April 25, 2014, 01:06:36 pm »

Quote
I think allowing beta-board access is something officially reserved for JimH, Matt, etc.
ahh no worries, anyway it's working well :) makes me wonder what else this technique could be used for 
Thanks
Logged
Pages: [1]   Go Up