INTERACT FORUM

Please login or register.

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

Author Topic: How To Make a Least Recently Played Smartlist  (Read 6896 times)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
How To Make a Least Recently Played Smartlist
« on: April 04, 2015, 11:32:55 am »

Another thread got me thinking about making a Least Recently Played smartlist.  I wanted to make a Least Recently Played smartlist that behaved like this:

* Sorts Never before Played tracks to the top.
* After that sorts tracks that have been played, with those played longest ago at the top.
* And so on and so forth with those most-recently played at the very bottom.

This can be somewhat challenging.  I describe the dilemma here:

This question made me quest to find a way to make a "perfect" Least Recently Played smartlist, and I just got it.  Figured I'd explained how.  First, since you're new here, I need to explain one of the oddities of how MC sorts...

In general, with the default options, MC sorts empty strings for any given field last.  This is often exactly what you want, because it "hides" items with missing data down at the bottom of the list.  So, for example, if you sort a list a-z on the [Name] field, it'll show you tracks "alphabetized" as you'd probably expect ("ascii-sorted", with special characters at the top, then numbers, then a-z).  What you don't get is a whole pile of tracks with the [Name] field completely blank at the top, even if you have some of these in your Library.  Those tracks that have a completely empty [Name] field always sort to the bottom, effectively "hiding them away".

This is usually what you want, but it does sometimes get in the way of sorting numeric fields.  That's because MC usually counts the value of zero as equivalent to empty (and in certain circumstances, actually counts 1 as equivalent to empty, such as for [Disc #]).  You can see this behavior if you try to sort on the [Number Plays] field.  It will sort from 1-N if you sort a-z style, and from N-1 if you sort z-a style, but the files with zero plays will always be at the bottom of the list.  That's because a zero in an Integer field is treated as empty, and MC sorts empty strings last.

If this feature always drives you nuts, you can turn it off via Tools > Options > Tree & View > Sorting > Sort empty strings last.  But, keeping it turned on is usually "right" and matches user expectations.

I decided to split this out into a separate post because it doesn't directly relate to the original question, and this thread topic will be easier for others to find in the future.
Logged
"Some cultures are defined by their relationship to cheese."

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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #1 on: April 04, 2015, 01:07:57 pm »

There are probably ways to work around this otherwise, but I think I came up with a clever way, and figured I'd pass it along.

[Played Ever] Field

First, you'll need a custom field that allows you to distinguish between tracks that have been Played before and those that have not, and which can be sorted "normally" instead of via MC's regular "empty strings last" behavior.  I called mine [Played Ever] but you can call it what you'd like.  To create a new field, open the Manage Library Fields editor under Tools > Options > Library & Folders > Manage Library Fields.

1. Click the Add New Field button to add a new custom field.
2. Type in the name you chose and click OK to create the field.

Next, modify the Data section.

Change the Field Data Type to Calculated Data, and enter the following expression in the box:
Code: [Select]
If(IsEmpty([Number Plays]),0,If(IsEmpty([Last Played,0]),1,2))

Click to embiggen


This will output:
0 - If [Number Plays] is equal to zero.
1 - If [Number Plays] is greater than zero, but [Last Played] is empty.
2 - If [Number Plays] is greater than zero and [Last Played] is not empty

I did this because when testing the system on my own system, I had a number of tracks that fell into the "middle category".  These were files that had a non-zero count of plays, but no record of when the last play had taken place (meaning, [Last Played] listed "never played" in the view).  I think this is a side effect of syncing data between iTunes and MC, or perhaps from very old upgrades of MC that changed the database format.  From my data set, it seems like most of them that fell in this category hadn't been played in a very long time, but certainly not "never".  I wanted to be able to distinguish between these types.

Data Types and Calculated Fields in the Manage Library Fields Dialog

Also, a note about the way the Data Type setup works in MC.  The default settings are User Data with the following settings:
Data Type: String
Relational: Not relational
Edit Type: Standard

When you switch to Calculated Data type instead of User Data, the User Data section greys out.  This probably shouldn't actually happen because the settings in User Data do still apply to the calculated field.

In this example, we want the field to be a String Type field (so that zero isn't counted as blank).  However, it is worth mentioning because you can use it to change the way Calculated fields behave and appear when displayed.  If you wanted this field to show in a column with checkmarks, you can do this, but you have to "trick" the dialog a little.

When you set the settings under User Data, they aren't applied until you click OK to close the dialog.  If when you close the dialog, you've selected Calculated Data as the field type, then any changes you've made to those settings are not saved and are discarded (they go back to the defaults listed above).  However, it will remember them if you do a little trick:

1. Open the field up and set it to User Data type.  This grays out and disables, but does not delete, any expression currently entered into the Calculated data expression box.
2. Set the settings in Data Type, Relational, Edit Type, and Acceptable Values as you see fit (the most useful of these to change is the Edit Type).
3. Close the dialog by hitting OK.  This "saves" those settings.
4. Open the Manage Library Fields dialog back up, and pick your field again.
5. Switch it back to a Calculated Data type field, and your expression will be "re-activated".



That's how you can make an Expression-type field display in MC with a checkbox (or Rating Stars or any of the other Edit Types).  You must close the Manage Library Fields dialog between steps 2 and 4, however, or the changes you make to the Edit Type or other options will not be saved.

Making The Smartlist

Lastly, now that we have a sortable field that will tell us if a file has ever been played or not, we need to use it in a Smartlist.  This is pretty straightforward now, and you can do it using the normal Smartlist Editor.  Here is mine:



If you want to just import mine, this is the code to use:
Code: [Select]
[Media Type]=[Audio] [Media Sub Type]=[],[Music] [Last Played]=>1d ~sort=[Played Ever],[Number Plays],[Last Played],[Date Imported],[Filename]
This Smartlist results in just what was described at the outset (with a little bonus if you have any of those "previously played but we don't know when" tracks):

* Shows all music tracks that weren't played within the last day.
* Tracks where [Number Plays] is zero sort to the top.
* Tracks where [Number Plays] is non-zero, but [Last Played] is empty sort next.
* Tracks where [Number Plays] is non-zero and [Last Played] is non-empty sort last, in order, with the least-most-recently-played tracks at the top of the "section" of the list.

And, within each of those "sections", if everything else is identical:

* The oldest tracks (those imported long ago) sort to the top.
* Where tracks were imported at the same exact time, the sort order is by Filename.

Those last two items are useful because otherwise MC's default behavior is to randomize the sort order.  This prevents this for tracks that otherwise "match" in all other ways.
Logged
"Some cultures are defined by their relationship to cheese."

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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #2 on: April 04, 2015, 01:17:49 pm »

A useful purpose of this list would be to have a shuffled version of the list, that always picks from the top N choices in the list generated above, and then shuffles them.  This is easy to add to the above Smartlist to create a "Play me a random selection of tracks that have either never been played, or were last played a long time ago" list.

I added a limit to this list that excludes files rated with 1 star, so that you can have it exclude tracks that you have evaluated, and decided you don't like (but those you don't just delete for some reason or another). I also added a filter that excludes tracks that are 11 minutes or longer in duration, so the list isn't full of tracks that are super-long (Alice's Restaurant, ambient electronica, and classical pieces for me, typically).


Click to embiggen


Code:
Code: [Select]
[Media Type]=[Audio] [Media Sub Type]=[],[Music] [Last Played]=>1d -[Rating]=1 [Duration]=<=660 ~sort=[Played Ever],[Number Plays],[Last Played],[Date Imported],[Filename] ~n=100 ~sort=Random
I think it is a pretty nifty list, so I thought it could be useful to some others.  If you play this list long enough, and rate things as you go, you'll eventually have listened to all of the files in your Library (maybe except those super-long tracks and the ones you hate), and always have a shuffled list at your fingertips comprised of those files that you listened to longest ago, or never before.

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

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

William-NM

  • World Citizen
  • ***
  • Posts: 115
Re: How To Make a Least Recently Played Smartlist
« Reply #3 on: April 04, 2015, 01:57:40 pm »

These are pretty cool, Glynor. Thanks for whipping them up!  Plus, it gave me a nice break from replacing / upgrading my library after a spectacular double-drive failure that wiped out most of my tunes. (25K are on Google Play Music, but they knock 'em down to 320kb, and I'm spoiled for HR anymore.) Now I just have to let my library 'age' a bit so the new smartlists can do their thing.  >:(
Logged

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #4 on: April 04, 2015, 02:54:56 pm »

I brought up this issue a few months back, because every morning, I have MC20 automatically play a shuffled playlist every morning from amongst all of my music that one might call "chamber music".

Despite including thousands of tracks, I tend to hear a certain track a second or third time, while other tracks are never played.

I started a new thread, and was pointed to a thread from several years ago, where the only suggestions were impossibly complicated expressions and procedures, so I tabled the issue.  (There are also other threads on the issue of the random shuffle play not being entirely random.)

This new method would seem to automatically solve all those problems, so I will give it a try.

Thanks for taking the time to create this.

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #5 on: April 04, 2015, 03:05:57 pm »

Quote
I added a limit to this list that excludes files rated with 1 star, so that you can have it exclude tracks that you have evaluated, and decided you don't like (but those you don't just delete for some reason or another).

I keep such tracks and albums (and rate them one star) for three reasons (all related to having listened to music for decades):

1) In the past I have deleted an album, forgotten it - because it is forgettable.  ;D - and then years later hear a couple of comments "Blah Blah Group are really excellent" - so I end up getting the album again, and only then remember that I hated and deleted it.  ;D

2) Sometimes, music that I disliked when I was young, I change my mind and like when I am older.

3) Sometimes, pressings and releases of albums that I thought were worse when I had lesser equipment, now are revealed to be superior (usually 1980s CDs that are actually better than the later remasters).

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #6 on: April 04, 2015, 04:48:16 pm »

I keep such tracks and albums (and rate them one star) for three reasons

Yep.  All the same reasons apply to me as well.  Plus one, for individual tracks:

4) Cruddy song(s) on otherwise good albums.  I never want these to show up in any of my "shuffles" (which always exclude 1-star tracks) but I don't want to delete them either for anal-retentive completionist reasons.
Logged
"Some cultures are defined by their relationship to cheese."

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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #7 on: April 04, 2015, 05:15:17 pm »

after a spectacular double-drive failure that wiped out most of my tunes.

Eeeghads!  >:( :'(

One thing I can recommend, if nothing else works... If the drive shows up to the BIOS, and is a IDE or SATA-type disk (or you can rip it out of the USB case and it is one inside the case), then I've had SpinRite save otherwise unrecoverable data from disks before.

Sometimes it can take a LONG time.  I had one failed disk that had a whole pile of bad sectors right at the beginning of the disk, and so which wouldn't mount.  But, I ran SpinRite on it (and it took 2 1/2 weeks to finish as it plowed through all those horribly damaged sectors).  When it was done, though, it recovered around 95% of the data on the disk.  The directory structures were smashed, but it was my parent's hard drive, and I got a bunch of otherwise-gone-forever personal photos back, which was easily worth the price in time (and SpinRite, though I already owned it).

So... It could work, if you haven't otherwise messed them up and written to them in your recovery efforts.

But, it doesn't work on disks:
* that are USB-native (like thumb drives)
* that have a damaged controller (where it doesn't show up to the BIOS or otherwise doesn't work like a disk should)
* have had severe head-crashes (where the drive reading head is mangled)
Logged
"Some cultures are defined by their relationship to cheese."

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

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #8 on: April 04, 2015, 05:38:30 pm »

Coincidentally, I just finished a backup of my music drive to another identical USB3 external drive, that then goes back into a fireproof box in a closet (along with a new power supply and the specialized USB cable).

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #9 on: April 04, 2015, 05:50:21 pm »

I assume that the Media-sub-type is only there to deal with some customization in your own library ?

Also FYI, in my setup, I have to have a rule "Channels <= 2".

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #10 on: April 04, 2015, 06:36:15 pm »

The Media Sub Type rule is there to prevent "non-music" files from showing up in the list.  This includes, in my Library:

* Podcasts
* Audiobooks
* Ringtones
* Voice Memos ([Media Sub Type]=Other, [Genre]=Voice Memo)
* Audio-only Movie Clips, and stuff like that ([Media Sub Type]=Stock, [Genre]=Movie Clips)
* TV Show Themes ([Media Sub Type]=Other, [Genre]=TV Themes)
* Exercise tracks, my wife has a collection of zumba mixes ([Media Sub Type]=Educational, [Genre]=Exercise)
* Halloween sounds ([Media Sub Type]=Stock, [Genre]=Halloween)
* System sounds (stuff like the windows "dings" which I import and manage in MC) ([Media Sub Type]=System)
* Test files ([Media Sub Type]=Test Clip)

I include the blank [Media Sub Type] to catch files that sneak in without being categorized with a proper [Media Sub Type].  All of my Auto-Import Watched Directories automatically set this to Music if it can't be automatically set correctly, but stuff sometimes sneaks in through other import mechanisms.
Logged
"Some cultures are defined by their relationship to cheese."

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

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #11 on: July 14, 2015, 08:01:48 pm »

This has been really valuable to me, so I thought I would bump it to the top before everyone leaves for the MC21 Forum. :D

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #12 on: July 14, 2015, 11:04:16 pm »

Good call, kstuart.

I added it to the Wiki:
http://wiki.jriver.com/index.php/Least_Recently_Played_Smartlist

It is just a stub that points to this thread, but that's fine for stuff like this. So you know, there are actually two categories in the Wiki that I try to use for things like this:

* Smartlist and Search Examples: http://wiki.jriver.com/index.php/Category:Search_Examples

That one is linked from the Smartlist page on the Wiki, so it is pretty easy to find.

* General Tutorials: http://wiki.jriver.com/index.php/Category:Tutorials

Some of these are actually written up on the Wiki, but more of them are pointers to threads.  It would be nice to collect and make stubs for more of them and tag them properly, so they show up in the list. The Tutorials category is a root category, so it shows up in the Category Index.

I added this thread to both, because it fits both categories.
Logged
"Some cultures are defined by their relationship to cheese."

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

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #13 on: July 15, 2015, 12:05:25 pm »

Is there a way to save any of the above changes, separately from a Library Backup ?

( For example, if you implemented all of the above today, and then had to restore from the June 1st library backup, is there a way to save any of it in a separate file? Or do you have to re-enter it by hand, as above? )

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How To Make a Least Recently Played Smartlist
« Reply #14 on: July 15, 2015, 12:14:28 pm »

The way to save it IS a Library Backup.
Logged
"Some cultures are defined by their relationship to cheese."

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

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: How To Make a Least Recently Played Smartlist
« Reply #15 on: July 15, 2015, 04:27:46 pm »

The way to save it IS a Library Backup.
Okay, but in my example, the Library Restore is from a date before one implements the Smartlist... so I guess the answer is no.

MusicBringer

  • Galactic Citizen
  • ****
  • Posts: 430
  • MC32.0.58 x64bit
Re: How To Make a Least Recently Played Smartlist
« Reply #16 on: July 15, 2015, 05:00:14 pm »

This has been really valuable to me

Umm, yeah, I have copied this and tweaked a few settings to suit my own ways.
I'll give it a try for a few days.
Like you I set up a shuffle first thing every morning.
I also like the one star rating idea for the "Cruddy songs"
This means that I'm gonna have to do a lot of rating now....and then of course all the altered music files will need to be backed up on my ext hard drives.
thanks,
Logged
Caesar adsum jam forte. Brutus aderat. Caesar sic in omnibus. Brutus sic inat.
Pages: [1]   Go Up