INTERACT FORUM

Please login or register.

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

Author Topic: Smartlists for "Played today" and "Played Yesterday"  (Read 4081 times)

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Smartlists for "Played today" and "Played Yesterday"
« on: March 09, 2010, 02:20:40 am »

Here's something that might be of interest to anyone who has sussed that the stock MC smartlist for "Played Today" actually returns files "Played in the last 24 hours" which is not quite the same thing.

So, to get a true list of files "Played Today", use the following expression:
[=isequal([last played],formatdate(now(),dd//MM//yyyy),8)]=1 ~sort=[last played]

And to get a true list of files "Played Yesterday", use:
[=isequal([last played],formatdate(math(now()-1),dd//MM//yyyy),8)]=1 ~sort=[Last Played]

These two strings can be equally, if not more, useful when used with "Date Imported"...

Imported Today:
[=isequal([date imported],formatdate(now(),dd//MM//yyyy),8)]=1 ~sort=[date imported]

Imported Yesterday
[=isequal([date imported],formatdate(math(now()-1),dd//MM//yyyy),8)]=1 ~sort=[date imported]

You may need to tweak the "dd//MM//yyyy" bits to match the format your system uses for dates. Check how MC populates a [date imported] or [last played] column for you, and adjust the string to match the format.

I've used the strings above as entries in a "Search List" category, and quite useful they are too!
If you're not sure what I mean by "Search List" category, follow this link and scroll down to the third heading titled "Categories (panes)" for an explanation.

Have fun,
-marko :)
 

Gl3nn

  • Galactic Citizen
  • ****
  • Posts: 384
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #1 on: March 10, 2010, 05:00:38 pm »

Thanks Marko but could you tell me how one strips off the time portion of [Last Played] so the comparison works?  I couldn't find anything useful in the wiki regarding syntax for these expressions.
Logged

Daydream

  • Citizen of the Universe
  • *****
  • Posts: 772
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #2 on: March 10, 2010, 09:38:10 pm »

I couldn't find anything useful in the wiki regarding syntax for these expressions.

I'm going offtopic here for a second. I believe the wiki describing the Functions has the wrong structure. Or maybe the reason for the current structure escapes me.

The 'examples' are examples of syntax. Not of the functions returning actual results. If I'm an extraterrestrial from somewhere (I am - to programmers) I need to know that 1 + 1 = 2, not only that the function Addition is 1 + 1. The practical outcome is not shown. For me the extraterrestrial the meaning of 1 + 1 can be your sign for a blue medusa or a flying carpet or anything in between (colorful enough?). Therefore the learning process is shot to hell.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
RE: Smartlists + general expression discussion.
« Reply #3 on: March 11, 2010, 01:23:25 am »

Thanks Marko but could you tell me how one strips off the time portion of [Last Played] so the comparison works?  I couldn't find anything useful in the wiki regarding syntax for these expressions.
First of all, I'll show you how to strip the time from [last played] in case you want it later somewhere else, then I'll explain why you don't need to do that in order for the above examples to work...

So, to strip the time from an MC default date field, you tell the expression engine to work with the raw library data by adding a zero to the field, like so: [last played,0]
You then use that with the FormatDate function to tell the expression engine how you would like the date to be formatted.
So, using the examples above, you would enter: formatdate([last played,0],dd//MM//yyyy)
You must use two 'forward slashes'. The first is referred to as an 'escape character' and tells the expression engine to treat the character that comes next literally, rather than a part of the expression formula itself. The end result is that a single forward slash is output in the expression result.

Why do you not need this extra typing in the four examples in post #1?
If you look at them, you will see ",8". This figure instructs the expression engine in how you would like the two components to be compared.
In this case, I've used the figure, 8, which means that the compare should be a 'case insensitive sub-string compare' or in plain english, "ignore the case, if [last played] contains this string, we have a match, and if not, we don't"

If the expression examples are not working for you, then the "day/month/year" (dd//MM//yyyy) part of the expression must be wrong for your locale. I think the USA use MM//dd//yyyy for example. Simply check how MC is displaying the date part of [last played] and mirror that in your expression, then everything should work as expected.

I couldn't find anything useful in the wiki regarding syntax for these expressions.
This Page on the wiki contains a list of expression functions, and endeavours to explain how to use them, which brings us to....

I'm going offtopic here for a second. I believe the wiki describing the Functions has the wrong structure. Or maybe the reason for the current structure escapes me.

The 'examples' are examples of syntax. Not of the functions returning actual results. If I'm an extraterrestrial from somewhere (I am - to programmers) I need to know that 1 + 1 = 2, not only that the function Addition is 1 + 1. The practical outcome is not shown. For me the extraterrestrial the meaning of 1 + 1 can be your sign for a blue medusa or a flying carpet or anything in between (colorful enough?). Therefore the learning process is shot to hell.
If you check the discussion tab of the wiki page linked above, which I presume is the one you're referring to, you'll see that over a year ago, I posted that I felt the page was a little inadequate and unwieldy. There are also currently two, possibly three expression functions that are so far not documented on that page, and I keep meaning to add them.
I will do, but, in the absence of any other firm ideas, they will get added in the same format as all the rest.

Way back, when expressions were first introduced, JRiver kept a simple web page buried in the 'dev zone' with a current list of expression functions. When the wiki was introduced, I basically ported that page into the wiki and kept adding to it, and that is why it is the way it is.

Any re-write of that page is going to take some time, so in order to for that time not be wasted, it needs to be 'done right' from the get-go.
I understand that you're saying you would find it more helpful if the expected output were given alongside the given syntax examples, which when compared to re-writing the entire page, possibly breaking it up into different pages, shouldn't take too long at all, but, is there anything else that you, or anyone else with an interest who's reading, can suggest for making the expression pages more user friendly?

-marko.

Gl3nn

  • Galactic Citizen
  • ****
  • Posts: 384
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #4 on: March 11, 2010, 11:14:00 am »

Thanks, Marko, as usual.  I appreciate very much your explanations and time taken to convey them.

I had already changed the order of mm and dd to match what's used here.  What I didn't understand by inspecting the [Last Played] field was that it was using a single "m and d".  Once I changed that, it worked fine.  I'm not sure how that's set or where one could look to clearly determine the format (I guessed basically - I certainly missed it yesterday!).

I found the page in the Wiki you referenced (and I certainly appreciate the work folks like you do in trying to flesh-out the wiki) but it just didn't provide enough info for someone like me who needs to really start at the beginning.  So, for instance, when you state: "...to strip the time from an MC default date field, you tell the expression engine to work with the raw library data by adding a zero to the field, like so: [last
played,0]", where is that described?  It's probably somewhere but it's hard to find.  Same with the two forward slash thing... or the ",8".

I consider these "expressions" in the same ballpark as "functions" in Microsoft Excel, if you've used that.  That's what I'd like to see somewhere in MC... or in the Wiki: detailed syntax.  Maybe it's buried somewhere in MC... I dunno... but it should be comprehensive and easily accessible.

My biggest frustration in using MC is not spending the time to learn how to use a feature but FINDING information!  I don't mind taking a hour to read what I need to read in order to understand... what I mind is taking an hour to run search after search to (maybe) find a thread or an article that only touches on a portion of it.  And I know that some of the advanced folks here get impatient with newbies asking what to them appear like dumb and lazy questions, so I use the forum reluctantly when I am stuck.

I love MC and I use it every day.  I just wish there was a better help function than the wiki.  I know that's not a popular opinion here but it's the way I feel.

Anyway... I REALLY appreciate your contributions and help!  Thank you!
Logged

Daydream

  • Citizen of the Universe
  • *****
  • Posts: 772
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #5 on: March 20, 2010, 08:58:50 pm »

Sorry for letting this fell by the side, this is a rather dear subject to me.

Marko, in relation to the last part of your message above, this is how I see the wiki explanation for expressions:

1) Expression description - short description what the expression does (already in the wiki)

2) Complete, generic, syntax description - right now it's within "examples" but its not total generic. I mean, using an example at random

IsEqual([Artist], [Album], 1) it's not a complete generic example, it's specific;

IsEqual([Artist], [Album], compare_type) it is generic.

I can't put the finger on it for everybody but this is where by brain gets a short-circuit every time, meaning I have to spend extra 5 seconds to understand something because at that point I have already been pushed down the stairs without the manual explaining how to fall :). In other words never use a term that hasn't been explained already. Not sure if that is possible. If it is, I'm gonna curse all the learning books about programming.

3) List and describe all the components of an expression. If [Artist] and [Album] can be left with a "self-explanatory" note (or none, or whatever), compare_type will need complete explaining of what each iteration of the variable does (already in the wiki for this specific function but not for others).

4) Examples. One should be enough if it exemplifies good enough the usage; more than one if the expression has some dual purpose (I've no idea, I'm just speaking out loud).

===

Now, since the topic mentions something about smartlists, I have a second thought in my head. I'm not sure if it's possible just by using smartlists and expressions (that may need to be expanded) but we would benefit greatly from more "database" using of the current database. I recently gave a shot to a certain monkey-named product (nothing to do with Monkey Audio). There was a (pretty big) section of fixing inconsistencies in my collection. I know MC has ways to clean file properties and the likes... but how would I know where to use them?

I'd like to have stock smartlists or any other approach telling me that I have multiple years inside the same album, that my album art is both in-folder and in tags (or just in either of them), that I have naming inconsistencies (artist names all in caps, inconsistent use of "the" -> Beatles and The Beatles, albums with missing or incomplete album leveling, albums with missing tracks, albums with mixed use of leading zeros for tracks #, etc). There should be a zillion smartlists for "No" - no cover art, no year, no artists, no album, no comments. Some can be whipped together in 3 seconds, since there are the simplest smartlists there can be; others can't be done at all currently. And all of them should be stock (come with MC, not lost in a topic at the mercy of the search engine) - especially if people are expected to learn how to use smartlists (or whatever else they may become) efficiently.

And I only talked about music. I may like a smartlist that lists all my albums with Genre marked "Soundtrack", not linked to any videos I have, marked "Movies". That linking I'm talking about probably is a call too close to home for that relational thingie we buried under 9 months of silence now. But I digress.

What do you guys think?
Logged

rick.ca

  • Citizen of the Universe
  • *****
  • Posts: 3729
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #6 on: March 20, 2010, 11:31:26 pm »

Quote
2) Complete, generic, syntax description...

YES!!!

Such documentation is not for casual reading. It's highly unlikely I'm going to read it until I'm in dire need of specific help. In such cases, I don't want vague suggestion of some ways an expression might be used. I want to know exactly how it works, in all it's possible variations. As painful as they are to read, I think a good model for what is required are Command Prompt help topics. They provide the exact syntax of the command, clearly distinguishing mandatory and optional parameters. And then all the possible parameters are defined and explained. Many of the existing entries meet or come close to this standard, but not all. Many times I've had to resort to trial and error to figure out how an expression works. Often, the problem is my own stupidity—but that's why I need explicit help.

It would also be helpful if there were more notes about how or in what circumstances a command might be used. Sometimes, even with examples, that's not clear. When I'm searching for a solution, such notes may be more likely to convey "this will solve your problem" than the description of the expression or examples.
Logged

Lasse_Lus

  • Citizen of the Universe
  • *****
  • Posts: 999
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #7 on: April 09, 2010, 06:21:39 am »

Marko this is really helpful of you,  :) i have used this before with "query today", but no luck on "yesterday"..so i invested some time...and the reason for me that the "yesterday query" with Math () does not work is the system (decimal) settings..you have "." between i guess, i have ","..MC shows decimals with comma but seems to work internaly with dots ..so the trick for people like me using decimal comma..is to convert the comma to "." and then run you formula..then it works like a charm..

The main reason i have not used this has been the speed, it takes quite a lot of time to query the database and i just thought it was like that...BUT i (think) have now noticed why, if you have a searchlist with your query of imported yesterday in a view, i have always assumed that query only look in the already filtered view, but according to the log it checks the hole database so if i set the same filter in the searchlist as i have already in the view, i will get the answer about 10 times faster !!

i started i thread about it here...http://yabb.jriver.com/interact/index.php?topic=57037.0
Logged
MT5FR

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4583
Re: Smartlists for "Played today" and "Played Yesterday"
« Reply #8 on: August 30, 2010, 06:17:50 pm »

i stumbled over a nice other for the day/24 hours problem.
this seems to do it well:
Code: [Select]
if(isempty([last played,0]),mid(now(),0,5),math(mid(now(),0,5)-mid([last played,0],0,5))i use the now for when last played is empty so that it can be used for calculations under album thumbs.

 :)
gab
Logged
Pages: [1]   Go Up