INTERACT FORUM

Please login or register.

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

Author Topic: Smart Display Fields: A Tip (and Some Help)  (Read 2351 times)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Smart Display Fields: A Tip (and Some Help)
« on: April 30, 2014, 12:03:12 am »

So, since I made my awesome [Plays] and [Watched] fields, I've gotten interested in making other smart "for display" fields in MC.  In both Theater View and Standard View, you can use them to great effect to "combine" the display of relevant data, in the smallest possible spot while still being clear.

Just compare in the screenshots in the Custom Watched Field tutorial linked above to what Theater View would need to include to show the same information with standard fields!  The [Plays] field contains both [Number Plays] and [Last Played] and does so with the date portion shrunken down so that it takes no more than 7 characters total (for "unknown") and it still displays the information you need.  When you're looking back at "how long ago" you watched the show (or listened to the track) you might care if it was last Tuesday for some reason, or last September, but once you get into years ago, the year part becomes the most significant portion.

I recently decided to improve on that with other fields, which MC calculates anyway (so replacing a writable field with a read-only expression isn't a big loss), and which require displaying multiple separate columns or fields or which are excessively verbose.

I'll explain one, and then I'd love some help with a second.
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: Smart Display Fields: A Tip (and Some Help)
« Reply #1 on: April 30, 2014, 12:11:49 am »

[Date (smart)]

Media Center has all sorts of dates it can display.  In my Standard Views, I have them all displayed together, largely, hidden over to the right-hand side where I can scroll to them if needed.  I've often used the [Year] field as a coarse identifier in the "immediately visible" area of Standard View (that which you can see without scrolling to the right), but this doesn't work well for all media types.

I thought this was pretty low-hanging fruit, since I already have it mostly done for my [Plays] field described in the Custom Watched Field tutorial.

So, here's a great field you can make:

Code: [Select]
Name: Date (smart)
Display: Date(s)
Flags: All

Expression:
if(compare(math(now() - [Date, 0]), <, 365), FormatDate([Date, 0], MMM dd,), FormatDate([Date, 0], yyyy,))

and, likewise:

Code: [Select]
Name: Date Imported (smart)
Display: Imported (for both)
Flags: All

Expression:
if(compare(math(now() - [Date Imported, 0]), <, 365), FormatDate([Date Imported, 0], MMM dd, unknown), FormatDate([Date Imported, 0], yyyy, unknown))

Set them both with Right-hand column alignment (or maybe Center) if you add them to Standard View.  I like to use the [Imported] version at the head of my "New Stuff" (most recently imported on top) Views I have throughout my Library.  And [Date (smart)] has replaced the [Year] column in essentially all of my Views.

Note: I messed this up in my copypasta above at first, and just fixed it.  The [Date (smart)] version I find works best if you blank out the "unknown" results, because they're more common cases (not all of my stuff is universally tagged with [Date], or reliable data, particularly among the audio files.  However, [Date Imported] should essentially never be undefined, so you want those cases to stick out like sore thumbs, if any exist at all.
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: Smart Display Fields: A Tip (and Some Help)
« Reply #2 on: April 30, 2014, 12:39:14 am »

So, that's one.  I have more, and I'll get to them later.

However, I'd love help with one.  I'd like to "modify" [Compression].  I'm reasonably sure this could be done with a fancy RegEx() but I'm hopeless and stumbling on my own (despite, doing as MrC and John Siracusa recommended and getting one of those RegEx buddy programs).

[Compression] has a few forms.  I'd like to transmute:

mkv video (video: MPEG-2 Video, audio: AC3) <> mkv (MPEG-2:AC3)
m4v video (video: AVC1, audio: MP4 AAC) <> m4v (AVC1:MP4 AAC)
ts video (video: AVC1, audio: AC3) <> ts (AVC1:AC3)


and so on and so forth.  If possible, I'd also like to (and I think the simplest means would be to have two separate versions of the custom field, one for video and one for audio):

CBR (MPEG-1 Layer 3) <> MP3 CBR
VBR (MPEG-1 Layer 3) <> MP3 VBR


And leave the rest of the possible audio values basically alone:

MP4 AAC
FLAC
APE
etc
Logged
"Some cultures are defined by their relationship to cheese."

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

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Smart Display Fields: A Tip (and Some Help)
« Reply #3 on: April 30, 2014, 12:42:35 am »

Don't forget to have a look at the various FormatDate() formaters.

Try:

  FormatDate(ShortDate)

for example.
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: Smart Display Fields: A Tip (and Some Help)
« Reply #4 on: April 30, 2014, 12:57:33 am »

How do you want these handled:

   CBR (MPEG-1.0 Layer 3)
   CBR (MPEG-2 Layer 3)

Edit:  I'll leave you with this for now.  This will handle video and audio:

ifelse(
   regex([compression], /#^(.+?) video \(video: (.+?)(?: Video)?, audio: (.+)\)#/), [R1] /([R2]:[R3]/),
   regex([compression], /#^([^(]+) \(MPEG-.*? Layer 3\)$#/), MP3 [R1],
   1, [compression]
)

Logged
The opinions I express represent my own folly.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Smart Display Fields: A Tip (and Some Help)
« Reply #5 on: April 30, 2014, 01:20:55 am »

Don't forget to have a look at the various FormatDate() formaters.

Try:

  FormatDate(ShortDate)

for example.

That's okay, but still not as small, and often includes information I really don't need to know or can imply by its absence (the year during the current year).
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: Smart Display Fields: A Tip (and Some Help)
« Reply #6 on: April 30, 2014, 01:23:05 am »

How do you want these handled:

   CBR (MPEG-1.0 Layer 3)
   CBR (MPEG-2 Layer 3)

For audio-only MP3 (and anything else where the distinction exists, though I don't think I have any) I don't really care about the details, just CBR vs VBR.  If I do, I can always look at the real [Compression] field (which I'll keep in Standard View, just way over to the right).

Oh yeah, and for anything blank, it would be nice to output [File Type].
Logged
"Some cultures are defined by their relationship to cheese."

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

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Smart Display Fields: A Tip (and Some Help)
« Reply #7 on: April 30, 2014, 02:06:15 am »

Ok, that's what I figured.

Replace the final [Compression] field in the above expression with: FirstNotEmty([Compression], [File Type]):


ifelse(
   regex([compression], /#^(.+?) video \(video: (.+?)(?: Video)?, audio: (.+)\)#/), [R1] /([R2]:[R3]/),
   regex([compression], /#^([^(]+) \(MPEG-.*? Layer 3\)$#/), MP3 [R1],
   1, FirstNotEmty([Compression], [File Type])
)
Logged
The opinions I express represent my own folly.

connersw

  • Citizen of the Universe
  • *****
  • Posts: 661
Re: Smart Display Fields: A Tip (and Some Help)
« Reply #8 on: April 30, 2014, 09:45:41 am »

Code: [Select]
Name: Date (smart)
Display: Date(s)
Flags: All

Expression:
if(compare(math(now() - [Date, 0]), <, 365), FormatDate([Date, 0], MMM dd,), FormatDate([Date, 0], yyyy,))

Returns 01 if the Date is 2014.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Smart Display Fields: A Tip (and Some Help)
« Reply #9 on: April 30, 2014, 10:38:37 am »

The expression needs to check the length of the [Date] field, which might be a year-only value, leading to output of "01" (default day value for year-only values), and no month.

  if(compare(length([date]), =, 4), year only value, full date value)
Logged
The opinions I express represent my own folly.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Smart Display Fields: A Tip (and Some Help)
« Reply #10 on: April 30, 2014, 12:26:16 pm »

Returns 01 if the Date is 2014.

Thanks.  The [Date] one was new, and I actually just saw a couple of those this morning before I walked out.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up