INTERACT FORUM

Please login or register.

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

Author Topic: MrC's Import panes  (Read 5314 times)

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
MrC's Import panes
« on: August 09, 2013, 04:44:16 am »

Here are the new columns using the new Int() math function, available in 19.0.23:

1. When Imported
Code: [Select]
save([date imported,0],thedate)/
if(isempty([thedate]), Bogus Date Imported,
   regex(now():[thedate], /#^(\d+)\.(\d+):(\d+)\.(\d+)$#/, -1)/
   save(math(int(abs([R1]>[R3]) / 7)),v_weeksago)/
   ifelse(
      compare([R1], =, [R3]),  Today\</
            math(1 + int((replace(removeright(formatdate([thedate], Elapsed),3), :, *60+)) / 60)) Hours Ago,
       compare(math([R1] - [R3]), =, 1), Yesterday,
       compare([v_weeksago],>, 52), Years Ago\math(int([v_weeksago]/52)) yr\/ math([v_weeksago] % 52) weeks,/
       1, Weeks Ago\math(int(abs([R1]>[R3]) / 7))
   );/
   ifelse(isequal(formatdate(now(), year.M), formatdate([thedate], year.M)), This Month);/
   ifelse(isequal(formatdate(now(), year),formatdate([thedate], year)), This Year)/
   ifelse(isequal(formatdate(now(), year.M.%U), formatdate([thedate], year.%U)), This Week);/
)&datatype=[list]

2. When Played
Code: [Select]
save([last played,0],thedate)/
if(isempty([thedate]), Never Played,
   regex(now():[thedate], /#^(\d+)\.(\d+):(\d+)\.(\d+)$#/, -1)/
   save(math(int(abs([R1]>[R3]) / 7)),v_weeksago)/
   ifelse(
       compare([R1], =, [R3]),  Today\</
            math(1 + int((replace(removeright(formatdate([thedate], Elapsed),3), :, *60+)) / 60)) Hours Ago,
       compare(math([R1] - [R3]), =, 1), Yesterday,
       compare([v_weeksago],>, 52), Years Ago\math(int([v_weeksago]/52)) yr\/ math([v_weeksago] % 52) weeks,/
       1, Weeks Ago\math(int(abs([R1]>[R3]) / 7))
   );/
   ifelse(isequal(formatdate(now(), year.M), formatdate([thedate], year.M)), This Month);/
   ifelse(isequal(formatdate(now(), year),formatdate([thedate], year)), This Year)/
   ifelse(isequal(formatdate(now(), year.M.%U), formatdate([thedate], year.%U)), This Week);/
)&datatype=[list]

I'm not sure what's going on but when I select '<0 Hours Ago', I get to see all my audio files which have been imported weeks/months ago.

When I add the 'Date Imported' field these dates are from 2012.

It looks like there's a little bug in there, somewhere.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #1 on: August 09, 2013, 12:19:44 pm »

Hmmm, you shouldn't see < 0 hours ago.

The expression takes the raw date imported, and outputs it as an elapsed time, like:

   1:02:30

which would be 1 hour 2 minutes and 30 seconds ago.  For recently imported items, it might look like:

   0:07

Then, it removes the seconds (e.g. :07) and leaves us with 0.  The Replace has no affect, and that leaves us with :

   math(1 + int((0) / 60)) Hours ago

which should result in 1 Hours Ago.  So I don't see how you get 0 from this.  This portion should only run when the imported (or played) date is the same as today's (they have the same integer portion of date).

Any more details?  Perhaps you can show some raw Date Imported values?  Use [Date Imported,0].
Logged
The opinions I express represent my own folly.

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: MrC's Import panes
« Reply #2 on: August 09, 2013, 12:22:14 pm »

Could it be a decimal point locale thing?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #3 on: August 09, 2013, 12:24:56 pm »

I was just wondering that too, so I tacked on a request to see the raw Date Imported values.  Perhaps output from FormatDate([Date Imported,0], Elapsed) would also be useful.
Logged
The opinions I express represent my own folly.

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: MrC's Import panes
« Reply #4 on: August 09, 2013, 12:29:39 pm »

Any more details?  Perhaps you can show some raw Date Imported values?  Use [Date Imported,0].

I was just wondering that too, so I tacked on a request to see the raw Date Imported values.  Perhaps output from FormatDate([Date Imported,0], Elapsed) would also be useful.

Sorry for being dim, but I should just add these as an expression pane? If yes, that will look like this.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #5 on: August 09, 2013, 12:31:19 pm »

I've got it.  I switched to Swedish, and see the problem.

Why can't the world pick one standard? I don't care which.  I'll learn Swedish, or German, or Swahili. :-)

Let me see what i can do.
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: MrC's Import panes
« Reply #6 on: August 09, 2013, 12:34:19 pm »

Change the regular expression to this in both panes:

   regex(now():[thedate], /#^(\d+)[.,](\d+):(\d+)[.,](\d+)$#/, -1)/

If you can test for other failures, I'd appreciate it.
Logged
The opinions I express represent my own folly.

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: MrC's Import panes
« Reply #7 on: August 09, 2013, 12:44:06 pm »

That works beautifully, thanks!

If I run into anything else I'll let you know.

Do you think the sort order could be adjusted to be chronological? Right now it sorts (descending) Yesterday, Weeks ago, Today, This Year, This month, unassigned.

Only if its easy to fix though and doesn't make it any slower. It's not that important, just nice to have ;).
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #8 on: August 09, 2013, 12:45:53 pm »

Thanks.

Re: the sort order - which one?  The panes, or file list?
Logged
The opinions I express represent my own folly.

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: MrC's Import panes
« Reply #9 on: August 09, 2013, 01:26:44 pm »

The 'When Imported' pane (your expression).
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #10 on: August 09, 2013, 01:31:45 pm »

I mentioned this in the other thread.

Create a custom sort Preset, using the Tab's Sort By > Custom.  Select Date Imported (z-a) or (a-z), for example, and save that as a Preset.

Then, you can change the expression column's Settings > Sort, selecting your preset.
Logged
The opinions I express represent my own folly.

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: MrC's Import panes
« Reply #11 on: August 10, 2013, 12:16:18 am »

I just learned something new; didn't know it worked that way :).

Thanks!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9132
Re: MrC's Import panes
« Reply #12 on: August 10, 2013, 05:28:11 pm »

Presumably down to the calculations involved, but I found these to be quite laggy.

I have not tried the expressions as saved library fields as opposed to expression based panes, though that has yielded better performance in this regard for me in other areas in the past.

Alternative option is in the attached file which contains a saved view 'jvi' file. Extract it to a "Saved Views" folder within your MC library folder, then use "View > Add View" to add it. Look for "Date Imported" in the view picker.

The view has "Honour parent scheme search rules" unchecked, so all media will be shown regardless of where it is added. The only filter in place is a genre exclusion of podcast.

It's just presented as another option, a little simpler, less process intensive, as productive (possibly), not a competition...

-marko

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #13 on: August 10, 2013, 06:44:50 pm »

I'm not sure if saving to a field will help, as Now() is being employed.  But we could try.

Try these changes.

1. Set rules for file display:

[=1save(formatdate(now(), year.M.%U;year.M;year),nowlist)]=1 ~sort=[Date Imported]-d

2. Replace the expression columns with these:

When Imported:
Code: [Select]
save([date imported,0],thedate)/
save(formatdate([thedate], year.M.%U;year.M;year),datelist)/
if(isempty([thedate]), Bogus Date Imported,
   regex(now():[thedate], /#^(\d+)[.,](\d+):(\d+)[.,](\d+)$#/, -1)/
   save(math(int(abs([R1]>[R3]) / 7)),v_weeksago)/
   ifelse(
       compare([R1], =, [R3]),  Today\</
            math(1 + int((replace(removeright(formatdate([thedate], Elapsed),3), :, *60+)) / 60)) Hours Ago,
       compare(math([R1] - [R3]), =, 1), Yesterday,
       compare([v_weeksago],>, 52), Years Ago\math(int([v_weeksago]/52)) yr\/ math([v_weeksago] % 52) weeks,/
       1, Weeks Ago\math(int(abs([R1]>[R3]) / 7))
   );/
   ifelse(isequal(listitem([nowlist],0), listitem([datelist],0)), This Week);/
   ifelse(isequal(listitem([nowlist],1), listitem([datelist],1)), This Month);/
   ifelse(isequal(listitem([nowlist],2), listitem([datelist],2)), This Year);/
)&datatype=[list]

When Played:
Code: [Select]
save([last played,0],thedate)/
save(formatdate([thedate], year.M.%U;year.M;year),datelist)/
if(isempty([thedate]), Never Played,
   regex(now():[thedate], /#^(\d+)[.,](\d+):(\d+)[.,](\d+)$#/, -1)/
   save(math(int(abs([R1]>[R3]) / 7)),v_weeksago)/
   ifelse(
       compare([R1], =, [R3]),  Today\</
            math(1 + int((replace(removeright(formatdate([thedate], Elapsed),3), :, *60+)) / 60)) Hours Ago,
       compare(math([R1] - [R3]), =, 1), Yesterday,
       compare([v_weeksago],>, 52), Years Ago\math(int([v_weeksago]/52)) yr\/ math([v_weeksago] % 52) weeks,/
       1, Weeks Ago\math(int(abs([R1]>[R3]) / 7))
   );/
   ifelse(isequal(listitem([nowlist],0), listitem([datelist],0)), This Week);/
   ifelse(isequal(listitem([nowlist],1), listitem([datelist],1)), This Month);/
   ifelse(isequal(listitem([nowlist],2), listitem([datelist],2)), This Year);/
)&datatype=[list]

These are calling FormatDate a lot less for the now() time, and saving the formatted values in a list.  It seems pretty snappy here w/almost 30k files.

I also noticed there was a semicolon missing on one of last lines:

      ifelse(isequal(formatdate(now(), year),formatdate([thedate], year)), This Year)/

It should be (and is corrected above):

  ifelse(isequal(formatdate(now(), year),formatdate([thedate], year)), This Year);/
Logged
The opinions I express represent my own folly.

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: MrC's Import panes
« Reply #14 on: August 11, 2013, 03:20:08 am »

Thanks again.

The speedbump with the latest changes is very nice. 60k files and its snappy!

Is it correct that the custom sort (as you explained above) is no longer working correctly?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #15 on: August 11, 2013, 04:29:24 am »

Good to hear.  The sorting preset should still work.  I have a sort in the Set rules for file display, but you can remove that if you want.
Logged
The opinions I express represent my own folly.

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: MrC's Import panes
« Reply #16 on: August 11, 2013, 06:13:32 am »

It gives me:

+Today
This Week
This Month
This Year
Yesterday
+Weeks Ago
Unassigned

Shouldn't Yesterday come after Today and Weeks Ago after This Week?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #17 on: August 12, 2013, 12:37:32 pm »

Keep in mind, the sorting for a collection of items considers all the items.  This Week and This Month will contain items played/imported today.  Therefore, in an aggregate sort, This Week and This Month will come before Yesterday when items are played/imported Today.

Edit:  While the above is true, I have a better answer for you.

It seems that the display version of Last Played (or Date Imported) does not sort correctly in terms of time.  To work around this problem, create a calculated field for both Last Played and Date Imported, using the expressions [Last Played,0] and [Date Imported,0], respectively.

Then, create sort Presets using those fields, call them Last Played (raw z-a) and Date Imported (raw z-a).  Sort on those presets in the expression columns.
Logged
The opinions I express represent my own folly.

Craig

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 612
Re: MrC's Import panes
« Reply #18 on: August 13, 2013, 03:51:45 pm »

MrC,

I've often wondered why you keep banging on about expressions and math and vars and such and now I know, this is dead cool, I just wish I had a clue how it was doing what it does.

Respect
Craig
Logged
MC2Slim - Windows Shell and JRiver Media Center Integration for Squeezebox.

http://www.duff-zapp.co.uk

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: MrC's Import panes
« Reply #19 on: August 13, 2013, 04:25:22 pm »

Thanks.  I'm not sure if I'm insulted or flattered.  But thanks.  :-)

ps. I'll explain how it works if it will be helpful.
Logged
The opinions I express represent my own folly.

Craig

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 612
Re: MrC's Import panes
« Reply #20 on: August 14, 2013, 01:55:20 am »

It was definitely meant as a compliment and no need to explain it, I'll dissect it myself and see what I can learn.

There may be questions though :-)

Craig
Logged
MC2Slim - Windows Shell and JRiver Media Center Integration for Squeezebox.

http://www.duff-zapp.co.uk
Pages: [1]   Go Up